Module: MtgCardMaker::DeepMerge
- Defined in:
- lib/mtg_card_maker/core_ext/deep_merge.rb
Overview
Deep merge functionality for nested configuration merging
Instance Method Summary collapse
Instance Method Details
#deep_merge(other_hash) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mtg_card_maker/core_ext/deep_merge.rb', line 6 def deep_merge(other_hash) merge(other_hash) do |_key, this_val, other_val| if this_val.is_a?(Hash) && other_val.is_a?(Hash) # Extend the inner hash with deep merge functionality this_val.dup.extend(DeepMerge).deep_merge(other_val) else other_val end end end |
#deep_merge!(other_hash) ⇒ Object
17 18 19 |
# File 'lib/mtg_card_maker/core_ext/deep_merge.rb', line 17 def deep_merge!(other_hash) replace(deep_merge(other_hash)) end |