Module: Aurb::CoreExt::Hash

Defined in:
lib/aurb/core_ext/hash.rb

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(key) ⇒ Object

Delegation



21
22
23
# File 'lib/aurb/core_ext/hash.rb', line 21

def method_missing(key)
  symbolize_keys[key.to_sym]
end

Instance Method Details

#symbolize_keysObject

Returns a new hash with all keys converted to symbols.



8
9
10
11
12
13
# File 'lib/aurb/core_ext/hash.rb', line 8

def symbolize_keys
  inject({}) do |options, (key, value)|
    options[(key.to_sym rescue key) || key] = value
    options
  end
end

#symbolize_keys!Object

Destructively converts all keys to symbols.



16
17
18
# File 'lib/aurb/core_ext/hash.rb', line 16

def symbolize_keys!
  replace symbolize_keys
end