-
Notifications
You must be signed in to change notification settings - Fork 313
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
Fix Hashie::Dash Defaults #63
Conversation
This also addresses #53 |
else | ||
begin | ||
value.dup | ||
rescue TypeError |
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.
What objects throw TypeError
when they're duped?
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.
According to the Rails docs, the non-duplicable objects are: nil, false, true, symbols, numbers, class objects and module objects.
👍 looks good to me. |
I've had a change of heart over the last few weeks over handling the Numeric case. If conciseness is desired, doing the minimal version is probably just as good:
|
Thanks @ohrite for the pull! I'm helping clean up issues and pulls and got commit access. If you don't mind, could you update your pull to use the concise version you described in the comment above? |
Previously, a Hashie::Dash's property's :default value was used by all instantiations. This change calls .dup on all non-Numeric default values during instantiation, rescuing from TypeError.
@jch updated to the concise version and ready to rock! |
Thanks! 🍻 |
Previously, a Hashie::Dash's property's :default value was used by all instantiations.
This change calls .dup on all non-Numeric default values during instantiation, rescuing from TypeError.