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

Merged
merged 1 commit into from May 23, 2012

Conversation

Projects
None yet
4 participants
Contributor

markmcspadden commented May 23, 2012

...deep_*_keys to use deep_transform_keys.

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

Open to suggestions.

@carlosantoniodasilva carlosantoniodasilva and 1 other commented on an outdated diff May 23, 2012

activesupport/CHANGELOG.md
@@ -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*
@carlosantoniodasilva

carlosantoniodasilva May 23, 2012

Owner

The last one should be deep_transform_keys!

@markmcspadden

markmcspadden May 23, 2012

Contributor

Yes. Fixed.

Contributor

lucashungaro commented May 23, 2012

Nice! :)

Contributor

markmcspadden commented May 23, 2012

@lucashungaro - you did the hard part :)

@rafaelfranca rafaelfranca and 1 other commented on an outdated diff May 23, 2012

activesupport/lib/active_support/core_ext/hash/keys.rb
# 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)
@rafaelfranca

rafaelfranca May 23, 2012

Owner

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

@markmcspadden

markmcspadden May 23, 2012

Contributor

Agreed. Fixed.

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