rails/rails — pull request #16388 by gchan (2014-08-04 04:57:52+00:00)
Title: HashWithIndifferentAccess#to_hash renamed to #deep_to_hash. Replacement #to_hash method only converts self to regular Hash.

Proposed change for #16247.

Currently `#to_hash` recursively converts any nested `HashWithIndifferentAccess` objects to regular a `Hash` which is inconsistent to the expected usage and behavior of `#to_*` methods.

It also has any impact on `HashWithIndifferentAccess#symbolize_keys` (discussed in #16247) such that the values of any nested hash can no longer be accessed indifferently. For example:

```ruby
hash_wia = {a: { b: 'b'} }.with_indifferent_access
=> {"a" => { "b" => "b" } }

hash_wia.symbolize_keys[:a][:b]
=> nil # I should expect nested hashes can still be indifferently accessible
```

This change reverts `#to_hash` back to the behavior prior to #10266 (nested hashes remain as `HashWithIndifferentAccess` and values are accessible by `Symbol` or `String`).

A `#deep_to_hash` method is added which implements the current behavior of #to_hash (converts nested hashes to regular hashes).