module TablePrint::HashExtensions::ConstructiveMerge
Public Instance Methods
constructive_merge(hash)
click to toggle source
# File lib/table_print/hash_extensions.rb, line 4 def constructive_merge(hash) target = dup hash.keys.each do |key| if hash[key].is_a? Hash and self[key].is_a? Hash target[key].extend ConstructiveMerge target[key] = target[key].constructive_merge(hash[key]) next end target[key] = hash[key] end target end
constructive_merge!(hash)
click to toggle source
# File lib/table_print/hash_extensions.rb, line 20 def constructive_merge!(hash) target = self hash.keys.each do |key| if hash[key].is_a? Hash and self[key].is_a? Hash target[key].extend ConstructiveMerge target[key] = target[key].constructive_merge(hash[key]) next end target[key] = hash[key] end target end