Skip to content

Allow identifiers to be defined with a block#110

Merged
mcclayton merged 1 commit intoprocore-oss:masterfrom
hugopeixoto:feature/pass-a-block-to-identifier
Oct 26, 2018
Merged

Allow identifiers to be defined with a block#110
mcclayton merged 1 commit intoprocore-oss:masterfrom
hugopeixoto:feature/pass-a-block-to-identifier

Conversation

@hugopeixoto
Copy link
Copy Markdown
Contributor

Now that ::association and ::field receive an optional block,
::identifier should receive it as well.

Since all three methods receive an optional block, the block extraction
mechanism was moved to AutoExtractor. Removing this mechanism from
each individual method made them very similar. ::association now uses
::field instead of directly adding the field to the current view.

Addresses #109

Comment thread lib/blueprinter/base.rb

def self.inherited(subclass)
subclass.send(:view_collection).inherit(view_collection)
def self.identifier(method, name: method, extractor: AutoExtractor.new, &block)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

Comment thread lib/blueprinter/base.rb
def self.inherited(subclass)
subclass.send(:view_collection).inherit(view_collection)
end
private_class_method :inherited
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great catch!

Now that `::association` and `::field` receive an optional block,
`::identifier` should receive it as well.

Since all three methods receive an optional block, the block extraction
mechanism was moved to `AutoExtractor`. Removing this mechanism from
each individual method made them very similar. `::association` now uses
`::field` instead of directly adding the field to the current view.
@hugopeixoto hugopeixoto force-pushed the feature/pass-a-block-to-identifier branch from fa9f3ff to 22b04ff Compare October 25, 2018 21:11
@hugopeixoto
Copy link
Copy Markdown
Contributor Author

I've added documentation. Feel free to suggest better examples, I used the one I needed on my project, but it may be a bit weird.

@philipqnguyen
Copy link
Copy Markdown
Contributor

LGTM!

@mcclayton
Copy link
Copy Markdown
Contributor

We’ll hopefully get this out soon in the next release of Blueprinter, thanks for this!

@mcclayton mcclayton merged commit 2b4c5d7 into procore-oss:master Oct 26, 2018
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.

4 participants