class IceCube::FlexibleHash

Find keys by symbol or string without symbolizing user input Due to the serialization format of ice_cube, this limited implementation is entirely sufficient

Public Instance Methods

[](key) click to toggle source
Calls superclass method
# File lib/ice_cube/flexible_hash.rb, line 11
def [](key)
  key = _match_key(key)
  super
end
delete(key) click to toggle source
Calls superclass method
# File lib/ice_cube/flexible_hash.rb, line 21
def delete(key)
  key = _match_key(key)
  super
end
fetch(key) click to toggle source
Calls superclass method
# File lib/ice_cube/flexible_hash.rb, line 16
def fetch(key)
  key = _match_key(key)
  super
end

Private Instance Methods

_match_key(key) click to toggle source
# File lib/ice_cube/flexible_hash.rb, line 28
def _match_key(key)
  return key if __getobj__.has_key? key
  if Symbol == key.class
    __getobj__.keys.detect { |k| return k if k == key.to_s }
  elsif String == key.class
    __getobj__.keys.detect { |k| return k if k.to_s == key }
  end
  key
end