Sha256: 7e058abfbd3b1dbf1615e6a60265e5ad8e6fd484276ad162cedfe6a96714cd99
Contents?: true
Size: 900 Bytes
Versions: 2
Compression:
Stored size: 900 Bytes
Contents
class Figgy # Stolen from Thor::CoreExt::HashWithIndifferentAccess # It's smaller and more grokkable than ActiveSupport's. class Hash < ::Hash def initialize(hash = {}) super() hash.each do |key, value| self[convert_key(key)] = value end end def [](key) super(convert_key(key)) end def []=(key, value) super(convert_key(key), value) end def delete(key) super(convert_key(key)) end def values_at(*indices) indices.collect { |key| self[convert_key(key)] } end def merge(other) dup.merge!(other) end def merge!(other) other.each do |key, value| self[convert_key(key)] = value end self end protected def convert_key(key) key.is_a?(Symbol) ? key.to_s : key end def method_missing(m, *args, &block) self[m] end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
figgy-0.9.0 | lib/figgy/hash.rb |
figgy-0.0.1 | lib/figgy/hash.rb |