Class: PartnerApi::Utils::Hash
- Inherits:
-
Object
- Object
- PartnerApi::Utils::Hash
- Defined in:
- lib/partner_api/utils/hash.rb
Class Method Summary collapse
-
.deep_merge(*hashes) ⇒ Object
This a simplify version of deep merging.
Class Method Details
.deep_merge(*hashes) ⇒ Object
This a simplify version of deep merging
In case both conflict items are hash, continue to merge recursively. Otherwise, prioritize the hash in later order
8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/partner_api/utils/hash.rb', line 8 def self.deep_merge(*hashes) hashes.inject({}) do |result, hash| result.merge(hash) do |_key, item_1, item_2| if item_1.is_a?(::Hash) && item_2.is_a?(::Hash) deep_merge(item_1, item_2) else item_2 || item_1 end end end end |