Class: MARS::Aggregator
Instance Attribute Summary collapse
-
#operation ⇒ Object
readonly
Returns the value of attribute operation.
Attributes inherited from Runnable
Instance Method Summary collapse
-
#initialize(name = "Aggregator", operation: nil, **kwargs) ⇒ Aggregator
constructor
A new instance of Aggregator.
- #run(context) ⇒ Object
Methods inherited from Runnable
Methods included from Hooks
included, #run_after_hooks, #run_before_hooks
Constructor Details
#initialize(name = "Aggregator", operation: nil, **kwargs) ⇒ Aggregator
Returns a new instance of Aggregator.
7 8 9 10 11 |
# File 'lib/mars/aggregator.rb', line 7 def initialize(name = "Aggregator", operation: nil, **kwargs) super(name: name, **kwargs) @operation = operation || ->(inputs) { inputs } end |
Instance Attribute Details
#operation ⇒ Object (readonly)
Returns the value of attribute operation.
5 6 7 |
# File 'lib/mars/aggregator.rb', line 5 def operation @operation end |
Instance Method Details
#run(context) ⇒ Object
13 14 15 16 |
# File 'lib/mars/aggregator.rb', line 13 def run(context) context = ensure_context(context) operation.call(context.current_input) end |