Class or method to convert hash keys to enable either string or symbol access?

I think I’ve seen this somewhere, but I can not recall where. Is there
some sort of class or method that will convert a hash so that all keys
may be accessed via a String or a Symbol, where the two are mapped
intelligently, and automatically upon assignment/creation of a key?

So like:

h[‘A key’] == h[:a_key]

?

On Mon, Jun 10, 2013 at 1:22 PM, Tamara T. [email protected]
wrote:

?

I usually use ‘hashie’ gem for this kind of stuff eg.

class Hash
include Hashie::Extensions::SymbolizeKeys
end

or,

class Hash
include Hashie::Extensions::MergeInitializer
include Hashie::Extensions::IndifferentAccess
end
etc.

On Mon, Jun 10, 2013 at 4:22 AM, Tamara T. [email protected]
wrote:

I think I’ve seen this somewhere, but I can not recall where.

h[‘A key’] == h[:a_key]

ActiveSupport::HashWithIndifferentAccess

On Jun 10, 2013 6:57 AM, “Marcin Rzeźnicki” [email protected]
wrote:

On Mon, Jun 10, 2013 at 1:22 PM, Tamara T. [email protected]
wrote:

?
class Hash
include Hashie::Extensions::MergeInitializer
include Hashie::Extensions::IndifferentAccess
end
etc.


Pozdrawiam
Marcin Rzeźnicki

Thanks, looks like this is what I need.