Class: ApipieBindings::IndifferentHash

Inherits:
Hash
  • Object
show all
Defined in:
lib/apipie_bindings/indifferent_hash.rb

Instance Method Summary collapse

Constructor Details

#initialize(constructor = {}) ⇒ IndifferentHash

Returns a new instance of IndifferentHash.



5
6
7
8
# File 'lib/apipie_bindings/indifferent_hash.rb', line 5

def initialize(constructor = {})
  super()
  merge!(constructor)
end

Instance Method Details

#[](k) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
# File 'lib/apipie_bindings/indifferent_hash.rb', line 10

def [](k)
  if has_key?(k)
    convert_value(super(k))
  elsif k.is_a?(Symbol) && has_key?(k.to_s)
    convert_value(super(k.to_s))
  elsif k.is_a?(String) && has_key?(k.to_sym)
    convert_value(super(k.to_sym))
  else
    convert_value(super(k))
  end
end