module SnakyHash
SnakyHash provides hash-like objects with automatic key conversion capabilities
@example Using StringKeyed hash
hash = SnakyHash::StringKeyed.new hash["camelCase"] = "value" hash["camel_case"] # => "value"
@example Using SymbolKeyed hash
hash = SnakyHash::SymbolKeyed.new hash["camelCase"] = "value" hash[:camel_case] # => "value"
@see SnakyHash::StringKeyed @see SnakyHash::SymbolKeyed @see SnakyHash::Snake
This is a module-class hybrid.
A flexible key conversion system that supports both String and Symbol keys, with optional serialization capabilities.
@example Basic usage with string keys
class MyHash < Hashie::Mash include SnakyHash::Snake.new(key_type: :string) end
@example Usage with symbol keys and serialization
class MySerializableHash < Hashie::Mash include SnakyHash::Snake.new(key_type: :symbol, serializer: true) end
Hashie's standard SymbolizeKeys is similar to the functionality we want. … but not quite. We need to support both String (for oauth2) and Symbol keys (for oauth). see: Hashie::Extensions::Mash::SymbolizeKeys