rails/rails — pull request #5576 by greggroth (2012-03-26 02:02:01+00:00)
Title: Recursive hash key methods

I've updated Hash#stringify_keys, Hash#stringify_keys!, Hash#symbolize_keys and Hash#symbolize_keys! to accept an option which applies the method recursively:

a = { :foo => "bar", :foo1 => { :nested_foo => "bar", :more_foo => "bar } }
a.stringify_keys
#=> { "foo" => "bar, "foo1" => { :nested_foo => "bar", :more_foo => "bar } }
a.stringify_keys(recursive: true)
#=> { "foo" => "bar, "foo1" => { "nested_foo" => "bar", "more_foo" => "bar } }

It also handles hashes nested within arrays well.