Class: IceCube::HashInput::Mash
- Inherits:
-
Object
- Object
- IceCube::HashInput::Mash
- Defined in:
- lib/ice_cube/hash_input.rb
Instance Method Summary collapse
-
#[](key) ⇒ Object
Fetch values indifferently by symbol or string key without symbolizing arbitrary string input.
-
#initialize(hash) ⇒ Mash
constructor
A new instance of Mash.
Constructor Details
#initialize(hash) ⇒ Mash
5 6 7 |
# File 'lib/ice_cube/hash_input.rb', line 5 def initialize(hash) @hash = hash end |
Instance Method Details
#[](key) ⇒ Object
Fetch values indifferently by symbol or string key without symbolizing arbitrary string input
12 13 14 15 16 17 18 19 |
# File 'lib/ice_cube/hash_input.rb', line 12 def [](key) @hash.fetch(key) do |key| str_key = key.to_s @hash.each_pair.detect do |sym_key, value| return value if sym_key.to_s == str_key end end end |