Sha256: dd3641e2f4a980634efb51ae9e8545f7a7ab0be32ff3ae27ee87fa11a11e4989
Contents?: true
Size: 484 Bytes
Versions: 1
Compression:
Stored size: 484 Bytes
Contents
class Hash def with_indiferent_access HashWithIndiferentAccess.new self end end class HashWithIndiferentAccess < Hash def initialize(hash=nil) merge! hash if hash end def [](key) if key?(key) || !transformable_key?(key) super else super transform_key(key) end end private def transformable_key?(key) key.is_a?(String) || key.is_a?(Symbol) end def transform_key(key) key.is_a?(String) ? key.to_sym : key.to_s end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
asynchronic-0.1.0 | lib/asynchronic/hash.rb |