Module: Plumbing::Pipeline::Operations
- Defined in:
- lib/plumbing/pipeline/operations.rb
Overview
Defining the operations that will be performed on the input data
Instance Method Summary collapse
-
#_call(input, instance) ⇒ Object
Internal use only.
-
#execute(method) ⇒ Object
Add an operation which does not alter the input data to the pipeline The output from the previous operation is fed in as the input to the this operation but the output from this operation is discarded and the previous input is fed in to the next operation.
-
#perform(method, using: nil) {|Object| ... } ⇒ Object
Add an operation to the pipeline Operations are processed in order, unless interrupted by an exception The output from the previous operation is fed in as the input to the this operation and the output from this operation is fed in as the input to the next operation.
Instance Method Details
#_call(input, instance) ⇒ Object
Internal use only
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/plumbing/pipeline/operations.rb', line 33 def _call input, instance validate_contract_for input validate_preconditions_for input result = input operations.each do |operation| result = operation.as(Callable).call(result, instance) end validate_postconditions_for result result end |
#execute(method) ⇒ Object
Add an operation which does not alter the input data to the pipeline The output from the previous operation is fed in as the input to the this operation but the output from this operation is discarded and the previous input is fed in to the next operation
24 25 26 27 28 29 30 |
# File 'lib/plumbing/pipeline/operations.rb', line 24 def execute method implementation ||= ->(input, instance) do instance.send(method, input) input end operations << implementation end |
#perform(method, using: nil) {|Object| ... } ⇒ Object
Add an operation to the pipeline Operations are processed in order, unless interrupted by an exception The output from the previous operation is fed in as the input to the this operation and the output from this operation is fed in as the input to the next operation
15 16 17 |
# File 'lib/plumbing/pipeline/operations.rb', line 15 def perform method, using: nil, &implementation using.nil? ? perform_internal(method, &implementation) : perform_external(method, using) end |