rails/rails — pull request #11659 by MatthewWear (2013-07-30 06:46:20+00:00)
Title: Fix for Hash#deep_transform_keys and Hash#deep_transform_keys!

The methods Hash#deep_stringify_keys and Hash#deep_symbolize_keys are not working as I would expect. They do not stringify or symbolize keys of hashes that are contained in nested arrays. For example, I would expect
```ruby
hash = { 'a' => { 'b' => [ { 'c' => 3 }, 4 ] } }

hash.deep_symbolize_keys
=> { :a => { :b => [ { :c => 3 }, 4 ] } } #expected behavior

hash.deep_symbolize_keys
=> { :a => { :b => [ { 'c' => 3 }, 4 ] } } #actual behavior
```
Digging through the source it became apparent that the culprit is the method Hash#deep_transform_keys. It does not traverse hashes that are contained in nested arrays. I've modified both Hash#deep_transform_keys and Hash#deep_transform_keys! to traverse hashes in nested arrays and added additional test cases for these scenarios. These changes result in the expected behavior of Hash#deep_stringify_keys and Hash#deep_symbolize_keys and their corresponding bang methods.