blueprinter
blueprinter copied to clipboard
Consistent field naming when aliasing
This fixes #281 by adding a new source:
option to fields, identifiers and associations, as a replacement for the name:
option.
The beauty of this approach is that the structure of the resulting JSON document can more easily recognized even when "squinting" and only looking at the first parameter of each field or association:
class MyBlueprint < Blueprinter::Base
identifier :uuid, source: :id
field :title, source: :title_string
association :owner, blueprint: UserBlueprint, source: :user
end
I tweaked all existing tests and made them pass. To get this out of draft state:
- [x] Agree on naming
- [ ] Add tests for deprecated
name:
options - [ ] Add deprecation warnings when using deprecated
name:
options
Checklist:
- [x] I have updated the necessary documentation
- [x] I have signed off all my commits as required by DCO
- [x] My build is green
I'm good with the approach, however, we need to support the older way as well and provide deprecation warnings for the same.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.