Module: SuperCallbacks::Helpers
- Defined in:
- lib/super_callbacks.rb
Class Method Summary collapse
-
.deep_merge_hashes_and_combine_arrays(this_hash, other_hash, &block) ⇒ Object
(modified) File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 18.
-
.deep_merge_hashes_and_combine_arrays!(this_hash, other_hash, &block) ⇒ Object
(modified) File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 23.
Class Method Details
.deep_merge_hashes_and_combine_arrays(this_hash, other_hash, &block) ⇒ Object
(modified) File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 18
24 25 26 |
# File 'lib/super_callbacks.rb', line 24 def self.deep_merge_hashes_and_combine_arrays(this_hash, other_hash, &block) self.deep_merge_hashes_and_combine_arrays!(this_hash.dup, other_hash, &block) end |
.deep_merge_hashes_and_combine_arrays!(this_hash, other_hash, &block) ⇒ Object
(modified) File activesupport/lib/active_support/core_ext/hash/deep_merge.rb, line 23
29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/super_callbacks.rb', line 29 def self.deep_merge_hashes_and_combine_arrays!(this_hash, other_hash, &block) this_hash.merge!(other_hash) do |key, this_val, other_val| if this_val.is_a?(Hash) && other_val.is_a?(Hash) self.deep_merge_hashes(this_val, other_val, &block) elsif this_val.is_a?(Array) && other_val.is_a?(Array) this_val + other_val elsif block_given? block.call(key, this_val, other_val) else other_val end end end |