Class: Attr::Gather::Aggregators::ShallowMerge
- Defined in:
- lib/attr/gather/aggregators/shallow_merge.rb
Overview
Shallowly merges results
Instance Method Summary collapse
- #call(input, execution_results) ⇒ Object
-
#initialize(reverse: false, merge_input: true) ⇒ ShallowMerge
constructor
private
Initialize a new DeepMerge aggregator.
Constructor Details
#initialize(reverse: false, merge_input: true) ⇒ ShallowMerge
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Initialize a new DeepMerge aggregator
18 19 20 21 22 |
# File 'lib/attr/gather/aggregators/shallow_merge.rb', line 18 def initialize(reverse: false, merge_input: true, **) @reverse = reverse @merge_input = merge_input super end |
Instance Method Details
#call(input, execution_results) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/attr/gather/aggregators/shallow_merge.rb', line 24 def call(input, execution_results) execution_results = execution_results.reverse_each if reverse? execution_results.reduce(@merge_input ? input : EMPTY_HASH) do |memo, res| memo.merge(unwrap_result(res)) end end |