Method: Hash#to_options
- Defined in:
- activesupport/lib/active_support/core_ext/hash/keys.rb
#to_options ⇒ Object
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"}
30 31 32 |
# File 'activesupport/lib/active_support/core_ext/hash/keys.rb', line 30 def symbolize_keys transform_keys { |key| key.to_sym rescue key } end |