blueprinter icon indicating copy to clipboard operation
blueprinter copied to clipboard

Consistent field naming when aliasing

Open franzliedke opened this issue 1 year ago • 1 comments

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

franzliedke avatar Feb 05 '24 22:02 franzliedke

I'm good with the approach, however, we need to support the older way as well and provide deprecation warnings for the same.

ritikesh avatar Feb 28 '24 11:02 ritikesh

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.

github-actions[bot] avatar Apr 29 '24 01:04 github-actions[bot]