module Hashie::Extensions::StringifyKeys::ClassMethods
def stringify_keys(hash)
-
hash
(::Hash
) --
def stringify_keys(hash) copy = hash.dup copy.extend(Hashie::Extensions::StringifyKeys) unless copy.respond_to?(:stringify_keys!) copy.tap do |new_hash| stringify_keys!(new_hash) end end
def stringify_keys!(hash)
-
hash
(::Hash
) --
def stringify_keys!(hash) hash.extend(Hashie::Extensions::StringifyKeys) unless hash.respond_to?(:stringify_keys!) hash.keys.each do |k| # rubocop:disable Performance/HashEachMethods stringify_keys_recursively!(hash[k]) hash[k.to_s] = hash.delete(k) end hash end
def stringify_keys_recursively!(object)
- Api: - private
def stringify_keys_recursively!(object) case object when self.class stringify_keys!(object) when ::Array object.each do |i| stringify_keys_recursively!(i) end when ::Hash stringify_keys!(object) end end