Skip to content
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

Coerce initializer parameter to_hash or to_h when it's not a Hash #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

nilbus
Copy link

@nilbus nilbus commented Aug 4, 2015

Passing hash-like objects that respond to #to_h or #to_hash will no longer fail to
work with lift's initializer when they didn't respond to #each_pair. Whenever we can
coerce the object to be a hash, do it, rather than forcing the caller to.

This can be used in situations like passing a JSON API response directly into the
initializer of a class that includes Lift, to create a value object out of the JSON
data.

Passing hash-like objects that respond to #to_h or #to_hash will no longer fail to
work with lift's initializer when they didn't respond to #each_pair. Whenever we can
coerce the object to be a hash, do it, rather than forcing the caller to.

This can be used in situations like passing a JSON API response directly into the
initializer of a class that includes Lift, to create a value object out of the JSON
data.
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.

None yet

1 participant