Module: CaseInsensitiveHash
- Defined in:
- lib/rbbt/util/misc/indiferent_hash.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.setup(hash) ⇒ Object
80 81 82 |
# File 'lib/rbbt/util/misc/indiferent_hash.rb', line 80 def self.setup(hash) hash.extend CaseInsensitiveHash end |
Instance Method Details
#[](key, *rest) ⇒ Object
94 95 96 97 98 99 |
# File 'lib/rbbt/util/misc/indiferent_hash.rb', line 94 def [](key, *rest) value = super(key, *rest) return value unless value.nil? key_downcase = key.to_s.downcase super(downcase_keys[key_downcase]) end |
#downcase_keys ⇒ Object
84 85 86 87 88 89 90 91 92 |
# File 'lib/rbbt/util/misc/indiferent_hash.rb', line 84 def downcase_keys @downcase_keys ||= begin down = {} keys.collect{|key| down[key.to_s.downcase] = key } down end end |
#values_at(*keys) ⇒ Object
101 102 103 104 105 |
# File 'lib/rbbt/util/misc/indiferent_hash.rb', line 101 def values_at(*keys) keys.collect do |key| self[key] end end |