instance method
symbolize_keys
Ruby on Rails 5.2.8.1
Since v3.0.20Signature
symbolize_keys()
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"}
Source
# File activesupport/lib/active_support/core_ext/hash/keys.rb, line 56
def symbolize_keys
transform_keys { |key| key.to_sym rescue key }
end
Defined in activesupport/lib/active_support/core_ext/hash/keys.rb line 56
· View on GitHub
· Improve this page
· Find usages on GitHub
Defined in Hash