Sha256: 44dc409f6b29d3a90121c7f7e6cd07248ac0c6fd101971b489e1c869b88579ee
Contents?: true
Size: 801 Bytes
Versions: 1
Compression:
Stored size: 801 Bytes
Contents
#-*- mode: ruby; coding: utf-8 -*- # # refer activesupport # # https://github.com/rails/rails/blob/master/activesupport/lib/active_support/core_ext/hash/deep_merge.rb # module ModulePlus module CoreExt module Hash def deep_merge(other_hash, &block) dup.deep_merge!(other_hash, &block) end # Same as +deep_merge+, but modifies +self+. def deep_merge!(other_hash, &block) merge!(other_hash) do |key, this_val, other_val| if this_val.is_a?(Hash) && other_val.is_a?(Hash) this_val.deep_merge(other_val, &block) elsif block_given? block.call(key, this_val, other_val) else other_val end end end end end end class Hash include ModulePlus::CoreExt::Hash end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
module_plus-0.1.0 | lib/module_plus/core_ext/hash.rb |