Sha256: ee24b23a368858ef89b64bc5e3d3ce91724c1b29c685c7baf48772168e4cbbf7
Contents?: true
Size: 610 Bytes
Versions: 13
Compression:
Stored size: 610 Bytes
Contents
# stolen from active_support 3.2.6 lib/active_support/core_ext/hash/keys.rb class Hash # Return a new hash with all keys converted to symbols, as long as # they respond to +to_sym+. # # { 'name' => 'Rob', 'years' => '28' }.symbolize_keys # #=> { :name => "Rob", :years => "28" } def symbolize_keys dup.symbolize_keys! end # Destructively convert all keys to symbols, as long as they respond # to +to_sym+. Same as +symbolize_keys+, but modifies +self+. def symbolize_keys! keys.each do |key| self[(key.to_sym rescue key) || key] = delete(key) end self end end
Version data entries
13 entries across 13 versions & 1 rubygems