Sha256: 51f7014e38c627b4c76075a1f1a8670586878e37d01e2c1bb4bc4f08af7fdc4a
Contents?: true
Size: 535 Bytes
Versions: 1
Compression:
Stored size: 535 Bytes
Contents
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
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
twitter-text-1.6.1 | lib/twitter-text/core_ext/hash.rb |