class ApipieBindings::IndifferentHash
Public Class Methods
new(constructor = {})
click to toggle source
Calls superclass method
# File lib/apipie_bindings/indifferent_hash.rb, line 5 def initialize(constructor = {}) super() merge!(constructor) end
Public Instance Methods
[](k)
click to toggle source
Calls superclass method
# 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
Private Instance Methods
convert_value(value)
click to toggle source
# File lib/apipie_bindings/indifferent_hash.rb, line 24 def convert_value(value) if value.kind_of?(Hash) && !value.is_a?(IndifferentHash) IndifferentHash.new(value) elsif value.kind_of?(Array) value.map { |v| convert_value(v) } else value end end