diff options
author | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-23 09:19:56 -0700 |
---|---|---|
committer | Carlos Antonio da Silva <carlosantoniodasilva@gmail.com> | 2012-05-23 09:19:56 -0700 |
commit | 541429fbe49b0671adb3842ab1818230d670ef9f (patch) | |
tree | 64a71bae017ae2a6d5fc701eff2dfd8e57b05cd0 /guides/source/active_support_core_extensions.textile | |
parent | c1487f619045840d89f1e2dbc6e133e1c2cbf2f4 (diff) | |
parent | a4bb195c91fa9bb25e136aa8850f3acafea0a597 (diff) | |
download | rails-541429fbe49b0671adb3842ab1818230d670ef9f.tar.gz rails-541429fbe49b0671adb3842ab1818230d670ef9f.tar.bz2 rails-541429fbe49b0671adb3842ab1818230d670ef9f.zip |
Merge pull request #6060 from lucashungaro/master
Adding deep versions of stringify_keys and symbolize_keys (plain and bang) for nested hashes
Diffstat (limited to 'guides/source/active_support_core_extensions.textile')
-rw-r--r-- | guides/source/active_support_core_extensions.textile | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/guides/source/active_support_core_extensions.textile b/guides/source/active_support_core_extensions.textile index 1f92d9d5f5..e2118e8f61 100644 --- a/guides/source/active_support_core_extensions.textile +++ b/guides/source/active_support_core_extensions.textile @@ -2611,6 +2611,13 @@ The second line can safely access the "type" key, and let the user to pass eithe There's also the bang variant +stringify_keys!+ that stringifies keys in the very receiver. +Besides that, one can use +deep_stringify_keys+ and +deep_stringify_keys!+ to stringify all the keys in the given hash and all the hashes nested into it. An example of the result is: + +<ruby> +{nil => nil, 1 => 1, :nested => {:a => 3, 5 => 5}}.deep_stringify_keys +# => {""=>nil, "1"=>1, "nested"=>{"a"=>3, "5"=>5}} +</ruby> + NOTE: Defined in +active_support/core_ext/hash/keys.rb+. h5. +symbolize_keys+ and +symbolize_keys!+ @@ -2645,6 +2652,13 @@ The second line can safely access the +:params+ key, and let the user to pass ei There's also the bang variant +symbolize_keys!+ that symbolizes keys in the very receiver. +Besides that, one can use +deep_symbolize_keys+ and +deep_symbolize_keys!+ to symbolize all the keys in the given hash and all the hashes nested into it. An example of the result is: + +<ruby> +{nil => nil, 1 => 1, "nested" => {"a" => 3, 5 => 5}}.deep_symbolize_keys +# => {nil=>nil, 1=>1, :nested=>{:a=>3, 5=>5}} +</ruby> + NOTE: Defined in +active_support/core_ext/hash/keys.rb+. h5. +to_options+ and +to_options!+ |