Class: IceCube::FlexibleHash

Inherits:
SimpleDelegator
  • Object
show all
Defined in:
lib/ice_cube/flexible_hash.rb

Overview

A way to symbolize what’s necessary on the fly Due to the serialization format of ice_cube, this limited implementation is entirely sufficient

Instance Method Summary collapse

Constructor Details

#initialize(hash) ⇒ FlexibleHash

Returns a new instance of FlexibleHash.



11
12
13
# File 'lib/ice_cube/flexible_hash.rb', line 11

def initialize(hash)
  @underlying = hash
end

Instance Method Details

#[](key) ⇒ Object



15
16
17
18
19
20
# File 'lib/ice_cube/flexible_hash.rb', line 15

def [](key)
  case key
  when String then @underlying[key] || @underlying[key.to_sym]
  else @underlying[key] || @underlying[key.to_s]
  end
end