Sha256: 0194bb4aa222e48704202d3d199a0a6f49277326961e3416b735b18df8b4492c
Contents?: true
Size: 650 Bytes
Versions: 13
Compression:
Stored size: 650 Bytes
Contents
class Hash # Same as Hash#merge but recursively merges sub-hashes. def recursive_merge(other) hash = self.dup other.each do |key, value| myval = self[key] if value.is_a?(Hash) && myval.is_a?(Hash) hash[key] = myval.recursive_merge(value) else hash[key] = value end end hash end # Same as Hash#merge! but recursively merges sub-hashes. def recursive_merge!(other) other.each do |key, value| myval = self[key] if value.is_a?(Hash) && myval.is_a?(Hash) myval.recursive_merge!(value) else self[key] = value end end self end end
Version data entries
13 entries across 13 versions & 2 rubygems