diff options
author | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-13 12:44:17 -0500 |
---|---|---|
committer | Francesco Rodriguez <lrodriguezsanc@gmail.com> | 2012-05-13 12:44:17 -0500 |
commit | cb61f57a02488c92e1dc8cc8e8fa52ed5f249955 (patch) | |
tree | f48a514708d7e5df48e5f2476a8f5b3aa089344b /activesupport/lib/active_support | |
parent | 873ac28660b6cec15064a4d321e121f68e54ee06 (diff) | |
download | rails-cb61f57a02488c92e1dc8cc8e8fa52ed5f249955.tar.gz rails-cb61f57a02488c92e1dc8cc8e8fa52ed5f249955.tar.bz2 rails-cb61f57a02488c92e1dc8cc8e8fa52ed5f249955.zip |
added example to Hash#stringify_keys
Diffstat (limited to 'activesupport/lib/active_support')
-rw-r--r-- | activesupport/lib/active_support/core_ext/hash/keys.rb | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/activesupport/lib/active_support/core_ext/hash/keys.rb b/activesupport/lib/active_support/core_ext/hash/keys.rb index 230a84dabc..f72582571f 100644 --- a/activesupport/lib/active_support/core_ext/hash/keys.rb +++ b/activesupport/lib/active_support/core_ext/hash/keys.rb @@ -1,5 +1,8 @@ class Hash # Return a new hash with all keys converted to strings. + # + # { :name => 'Rob', :years => '28' }.stringify_keys + # #=> { "name" => "Rob", "years" => "28" } def stringify_keys result = {} keys.each do |key| @@ -8,7 +11,8 @@ class Hash result end - # Destructively convert all keys to strings. + # Destructively convert all keys to strings. Same as + # +stringify_keys+, but modifies +self+. def stringify_keys! keys.each do |key| self[key.to_s] = delete(key) |