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 HashWithIndifferentAccess#to_hash behaviour #10266
Conversation
@@ -229,7 +229,11 @@ def to_options!; self end | |||
|
|||
# Convert to a regular hash with string keys. | |||
def to_hash | |||
Hash.new(default).merge!(self) | |||
_new_hash= {} |
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.
Please suggest on a faster way to copy to a new hash if any.
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 think this is the best one
Could you add a test case? |
adding |
added |
@rafaelfranca anything else, I should update? |
@rafaelfranca 1 month ping. Anything else this needs to handle? |
fix HashWithIndifferentAccess#to_hash behaviour
Hmm, seems a bit counterintuitive to me - the method isn't called e.g. |
Currently
HashWithIndifferentAccess#to_hash
,returns a hash containing HashWithIndifferentAccess within for a nested hash, egif
{:a => {:b => {:c => '3'}}}
is a HashWithIndifferentAccessthen #to_hash returns
{:a => {:b => {:c => '3'}}}
where {:b => {:c => '3'}} is a
HashWithIndifferentAccess
object, while the whole object itself is aHash