Method: Hash#symbolize_keys

Defined in:
lib/active_support/core_ext/hash/keys.rb

#symbolize_keysObject Also known as: to_options

Returns a new hash with all keys converted to symbols, as long as they respond to to_sym.

hash = { 'name' => 'Rob', 'age' => '28' }

hash.symbolize_keys
# => {:name=>"Rob", :age=>"28"}


54
55
56
# File 'lib/active_support/core_ext/hash/keys.rb', line 54

def symbolize_keys
  transform_keys { |key| key.to_sym rescue key }
end