Skip to content
This repository has been archived by the owner on Sep 18, 2021. It is now read-only.

Move Hash symbolize_keys/symbolize_keys! to a helper module. #90

Merged
merged 1 commit into from
Apr 17, 2013

Conversation

dadah89
Copy link
Contributor

@dadah89 dadah89 commented Apr 16, 2013

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).

Implement symbolize_keys and symbolize_keys! as a helper (HashHelper),
avoiding conflicts with projects stuck with old activerecord (~> 2.3.18)
and/or old Rails (2).
@jakl
Copy link
Contributor

jakl commented Apr 17, 2013

This looks good to me, thanks.

jakl added a commit that referenced this pull request Apr 17, 2013
Move Hash symbolize_keys/symbolize_keys! to a helper module.
@jakl jakl merged commit 41f3500 into twitter-archive:master Apr 17, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants