Sha256: c43306492b06e0813e607971d7373476fc6917ccd6e069a99e721dcad8e6bb97
Contents?: true
Size: 669 Bytes
Versions: 2
Compression:
Stored size: 669 Bytes
Contents
class Hash # Return a new hash with all keys converted to strings. def stringify_keys inject({}) do |options, (key, value)| options[key.to_s] = value options end end # Destructively convert all keys to strings. def stringify_keys! keys.each do |key| self[key.to_s] = delete(key) end self end # Return a new hash with all keys converted to symbols. def symbolize_keys inject({}) do |options, (key, value)| options[(key.to_sym rescue key) || key] = value options end end # Destructively convert all keys to symbols. def symbolize_keys! self.replace(self.symbolize_keys) end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ripple-anaf-0.8.0.beta2 | lib/ripple-anaf/core_ext/hash.rb |
ripple-anaf-0.8.0.beta1 | lib/ripple-anaf/core_ext/hash.rb |