Class: Wrest::HashWithCaseInsensitiveAccess
- Defined in:
- lib/wrest/hash_with_case_insensitive_access.rb
Overview
Instance Method Summary collapse
- #[](key) ⇒ Object
- #[]=(key, value) ⇒ Object
- #delete(key) ⇒ Object
-
#initialize(hash = {}) ⇒ HashWithCaseInsensitiveAccess
constructor
:nodoc:.
- #merge(other) ⇒ Object
- #merge!(other) ⇒ Object
- #values_at(*indices) ⇒ Object
Methods included from CoreExt::Hash::Conversions
Constructor Details
#initialize(hash = {}) ⇒ HashWithCaseInsensitiveAccess
:nodoc:
12 13 14 15 16 17 |
# File 'lib/wrest/hash_with_case_insensitive_access.rb', line 12 def initialize(hash={}) super() hash.each do |key, value| self[convert_key(key)] = value end end |
Instance Method Details
#[](key) ⇒ Object
18 19 20 |
# File 'lib/wrest/hash_with_case_insensitive_access.rb', line 18 def [](key) super(convert_key(key)) end |
#[]=(key, value) ⇒ Object
22 23 24 |
# File 'lib/wrest/hash_with_case_insensitive_access.rb', line 22 def []=(key, value) super(convert_key(key), value) end |
#delete(key) ⇒ Object
26 27 28 |
# File 'lib/wrest/hash_with_case_insensitive_access.rb', line 26 def delete(key) super(convert_key(key)) end |
#merge(other) ⇒ Object
34 35 36 |
# File 'lib/wrest/hash_with_case_insensitive_access.rb', line 34 def merge(other) dup.merge!(other) end |
#merge!(other) ⇒ Object
38 39 40 41 42 43 |
# File 'lib/wrest/hash_with_case_insensitive_access.rb', line 38 def merge!(other) other.each do |key, value| self[convert_key(key)] = value end self end |
#values_at(*indices) ⇒ Object
30 31 32 |
# File 'lib/wrest/hash_with_case_insensitive_access.rb', line 30 def values_at(*indices) indices.collect { |key| self[convert_key(key)] } end |