Class: Buckaruby::Support::CaseInsensitiveHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/buckaruby/support/case_insensitive_hash.rb

Overview

The case insensitive Hash is a Hash with case insensitive keys that can also be accessed by using a Symbol.

Instance Method Summary collapse

Constructor Details

#initialize(constructor = {}) ⇒ CaseInsensitiveHash

Returns a new instance of CaseInsensitiveHash.



8
9
10
11
12
13
14
15
# File 'lib/buckaruby/support/case_insensitive_hash.rb', line 8

def initialize(constructor = {})
  if constructor.is_a?(Hash)
    super()
    update(constructor)
  else
    super(constructor)
  end
end

Instance Method Details

#[](key) ⇒ Object



17
18
19
# File 'lib/buckaruby/support/case_insensitive_hash.rb', line 17

def [](key)
  super(convert_key(key))
end

#[]=(key, value) ⇒ Object



21
22
23
# File 'lib/buckaruby/support/case_insensitive_hash.rb', line 21

def []=(key, value)
  super(convert_key(key), value)
end