Sha256: 1ba4e4d7aa7ccbf7b32bbd2135b28343b0b4392bbb3ca698fa0cb3c9932c56cc
Contents?: true
Size: 543 Bytes
Versions: 14
Compression:
Stored size: 543 Bytes
Contents
class Hash def reverse_merge(other_hash) other_hash.merge(self) end def reverse_merge!(other_hash) replace(reverse_merge(other_hash)) end def deep_transform_keys(&block) result = {} each do |key, value| result[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys(&block) : value end result end def deep_transform_keys!(&block) keys.each do |key| value = delete(key) self[yield(key)] = value.is_a?(Hash) ? value.deep_transform_keys!(&block) : value end self end end
Version data entries
14 entries across 14 versions & 1 rubygems