Module: Dapp::CoreExt::Hash
- Defined in:
- lib/dapp/core_ext/hash.rb
Overview
Hash
Instance Method Summary collapse
-
#in_depth_merge(hash) ⇒ Object
do not conflict with activesupport`s deep_merge.
Instance Method Details
#in_depth_merge(hash) ⇒ Object
do not conflict with activesupport`s deep_merge
6 7 8 9 10 11 12 13 14 15 16 |
# File 'lib/dapp/core_ext/hash.rb', line 6 def in_depth_merge(hash) # do not conflict with activesupport`s deep_merge merge(hash) do |_, v1, v2| if v1.is_a?(::Hash) && v2.is_a?(::Hash) v1.in_depth_merge(v2) elsif v1.is_a?(::Array) || v2.is_a?(::Array) [v1, v2].flatten else v2 end end end |