twitter/twitter-text-rb — pull request #90 by dadah89 (2013-04-16 01:46:53+00:00)
Title: Move Hash symbolize_keys/symbolize_keys! to a helper module.

Just wanted to start a discussion/issue, figured out it'd be easier showing some code, hope that is OK.

The issue happens when trying to add twitter-text-rb as a dependency of an application where old activerecord (e.g. 2.3.18) is also a dependency (e.g. Rails 2 app).

activerecord 2, the `Hash` symbolize_keys method used to return a new `Hash`, and `HashWithIndifferentAccess` relied on that behavior (it doesn't overwrite that method).

With the current `lib/twitter-text/core_ext/hash` extension, `HashWithIndifferentAccess#symbolize_keys` returns a new `HashWithIndifferentAccess` instead, which can cause unexpected behavior (e.g. `HashWithIndifferentAccess.new('test' => 1).symbolize_keys.each { |k, v| puts k; }` returns strings as keys instead of symbols).

I know it's a corner case, but it'd be nice for people still stuck with old activerecord (~> 2.3.18) and/or old Rails (2).