Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/cloudapp/core_ext.rb

Overview

:nodoc:

Instance Method Summary (collapse)

Instance Method Details

- (Object) symbolize_keys

Return a new hash with all keys converted to symbols.



4
5
6
7
8
9
# File 'lib/cloudapp/core_ext.rb', line 4

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

- (Object) symbolize_keys!

Destructively convert all keys to symbols.



12
13
14
# File 'lib/cloudapp/core_ext.rb', line 12

def symbolize_keys!
  self.replace(self.symbolize_keys)
end