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

Add Hash#deep_transform_keys and Hash#deep_transform_keys! Also convert ... #6466

Merged
merged 1 commit into from May 23, 2012

Conversation

markmcspadden
Copy link
Contributor

...deep_*_keys to use deep_transform_keys.

Generalizes the deep_stringify_keys and friends that were added by @lucashungaro.

Open to suggestions.

@@ -1,6 +1,6 @@
## Rails 4.0.0 (unreleased) ##

* Add `Hash#transform_keys` and `Hash#transform_keys!`. *Mark McSpadden*
* Add `Hash#transform_keys`, `Hash#transform_keys!`, `Hash#deep_transform_keys`, and `Hash#transform_keys!`. *Mark McSpadden*

Choose a reason for hiding this comment

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

The last one should be deep_transform_keys!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes. Fixed.

@lucashungaro
Copy link
Contributor

Nice! :)

@markmcspadden
Copy link
Contributor Author

@lucashungaro - you did the hard part :)

# This includes the keys from the root hash and from all
# nested hashes.
def deep_stringify_keys!
def deep_transform_keys!(&block)
keys.each do |key|
val = delete(key)
Copy link
Member

Choose a reason for hiding this comment

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

what do you think about use a uniforma name to the value? In one methods is val in other is value

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Agreed. Fixed.

rafaelfranca added a commit that referenced this pull request May 23, 2012
Add Hash#deep_transform_keys and Hash#deep_transform_keys! Also convert ...
@rafaelfranca rafaelfranca merged commit 7a23ada into rails:master May 23, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants