Class: Hash

Inherits:
Object
  • Object
show all
Defined in:
lib/conductor/hash.rb

Overview

Hash helpers

Instance Method Summary collapse

Instance Method Details

#symbolize_keysHash

Convert all keys in hash to symbols. Works on nested hashes

Returns:

  • (Hash)

    hash with keys as symbols

See Also:



23
24
25
# File 'lib/conductor/hash.rb', line 23

def symbolize_keys
  each_with_object({}) { |(k, v), hsh| hsh[k.to_sym] = (v.is_a?(Hash) || v.is_a?(Array)) ? v.symbolize_keys : v }
end

#symbolize_keys!Hash

Destructive version of #symbolize_keys

Returns:

  • (Hash)

    hash with keys as symbols

See Also:



12
13
14
# File 'lib/conductor/hash.rb', line 12

def symbolize_keys!
  replace symbolize_keys
end