Method: Hash#symbolize_keys

Defined in:
lib/core/facets/hash/symbolize_keys.rb

#symbolize_keys(&select) ⇒ Object

Return a new hash with all keys converted to symbols. With a select block, limits conversion to only a certain selection of keys.

foo = { :name=>'Gavin', 'wife'=>:Lisa }
foo.symbolize_keys    #=>  { :name=>"Gavin", :wife=>:Lisa }
foo                   #=>  { :name =>"Gavin", "wife"=>:Lisa }

If the key does not respond to #to_sym, then #to_s will be used first.

For a more versatile method, see #rekey instead.



18
19
20
# File 'lib/core/facets/hash/symbolize_keys.rb', line 18

def symbolize_keys(&select)
  dup.symbolize_keys!(&select)
end