8000 Explicitly Cast Field/Association method argument to Symbol by lessthanjacob · Pull Request #505 · procore-oss/blueprinter · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

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

Merged
merged 3 commits into from
Feb 18, 2025

Conversation

lessthanjacob
Copy link
Contributor
@lessthanjacob lessthanjacob commented Feb 18, 2025

Changelog

Checklist:

  • I have updated the necessary documentation
  • I have signed off all my commits as required by DCO
  • My build is green

… Symbol

Signed-off-by: Jacob Sheehy <jacobjsheehy@gmail.com>
@lessthanjacob lessthanjacob self-assigned this Feb 18, 2025
@lessthanjacob lessthanjacob requested review from ritikesh and a team as code owners February 18, 2025 03:41
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:
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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).

Copy link
Contributor Author

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}"

Copy link
Contributor

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>
@lessthanjacob lessthanjacob force-pushed the js/coerce-field-association-method branch from 274f276 to 6ab0fa4 Compare February 18, 2025 19:21
@lessthanjacob lessthanjacob merged commit b371d72 into main Feb 18, 2025
6 checks passed
@lessthanjacob lessthanjacob deleted the js/coerce-field-association-method branch February 18, 2025 21:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants
0