Class: ActiveOperation::Pipeline
- Defined in:
- lib/active_operation/pipeline.rb
Defined Under Namespace
Classes: OperationFactory
Instance Attribute Summary
Attributes inherited from Base
Class Method Summary collapse
Methods inherited from Base
#call, call, #completed?, #halted?, #initialize, inputs, perform, #perform, #succeeded?, to_proc
Constructor Details
This class inherits a constructor from ActiveOperation::Base
Class Method Details
.compose(*operations, &block) ⇒ Object
41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/active_operation/pipeline.rb', line 41 def compose(*operations, &block) raise ArgumentError, "Expects either an array of operations or a block with configuration instructions" unless !!block ^ !operations.empty? if block Class.new(self, &block) else Class.new(self) do operations.each do |operation| use operation end end end end |
.operations ⇒ Object
25 26 27 |
# File 'lib/active_operation/pipeline.rb', line 25 def operations [] end |
.use(operation, options = {}) ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 |
# File 'lib/active_operation/pipeline.rb', line 29 def use(operation, = {}) if operations.empty? inputs = operation.inputs inputs.each do |input| input input.name, type: input.type end end (@operations ||= []) << OperationFactory.new(operation, ) end |