-
Notifications
You must be signed in to change notification settings - Fork 113
Explicitly Cast Field/Association method argument to Symbol #505
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
… Symbol Signed-off-by: Jacob Sheehy <jacobjsheehy@gmail.com>
Signed-off-by: Jacob Sheehy <jacobjsheehy@gmail.com>
@@ -51,7 +51,7 @@ def identifier(method, name: method, extractor: Blueprinter.configuration.extrac | |||
name, | |||
extractor, | |||
self, | |||
block: block | |||
block: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this intentional? I see it in three places, and it seems like block
would no longer be passed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's a side-effect of my local rubocop
auto-correction based on this 3.1+ change.
This should function exactly as before, but let me double check that we have proper test coverage here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fwiw I tried to duplicate it in a local script but only nil got passed. I may have done it wrong, though (Ruby 3.2).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just added a spec that covers the case when an identifier
is leveraging a block.
How did you specify this locally? This is working for me on 3.1
(I'll wait to see if the tests pass on 3.2
as well):
irb(main):001* class WidgetBlueprint < Blueprinter::Base
irb(main):002* identifier :id do |object, _options|
irb(main):003* object.id * 2
irb(main):004* end
irb(main):005> end
=>
#<Blueprinter::Field:0x0000000102c9ea48
@blueprint=WidgetBlueprint,
@extractor=
#<Blueprinter::AutoExtractor:0x0000000102e879e0
@block_extractor=#<Blueprinter::BlockExtractor:0x0000000102e87800>,
@datetime_formatter=#<Blueprinter::DateTimeFormatter:0x0000000102e87760>,
@hash_extractor=#<Blueprinter::HashExtractor:0x0000000102e87940>,
@public_send_extractor=#<Blueprinter::PublicSendExtractor:0x0000000102e878a0>>,
@method=:id,
@name=:id,
@options={:block=>#<Proc:0x0000000102e876c0 (irb):2>}>
irb(main):006> Widget = Struct.new(:id)
=> Widget
irb(main):007> WidgetBlueprint.render(Widget.new(1))
=> "{\"id\":2}"
irb(main):008> WidgetBlueprint.render(Widget.new(2))
=> "{\"id\":4}"
irb(main):009> WidgetBlueprint.render(Widget.new(3))
=> "{\"id\":6}"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nvm, I made a dumb mistake. Carry on!
Signed-off-by: Jacob Sheehy <jacobjsheehy@gmail.com>
274f276
to
6ab0fa4
Compare
Changelog
Checklist: