class Linearly::Flow::Contract
{Contract} is a companion for the {Flow}, providing it with logic for properly determining required inputs
and expected outputs
.
Attributes
inputs[R]
Inputs required for the {Flow}
@return [Hash<Symbol, TrueClass>] @api private
outputs[R]
Outputs provided by the {Flow}
@return [Hash<Symbol, TrueClass>] @api private
Public Class Methods
new(steps)
click to toggle source
Constructor for the {Contract}
@param steps [Array<Step>] array of things that implement the Step
interface (+call+, +inputs+ and +outputs+ methods).
@api private
# File lib/linearly/flow.rb, line 111 def initialize(steps) @steps = steps @inputs = {} @outputs = {} build end
Private Instance Methods
build()
click to toggle source
Figure out inputs required and outputs provided by the {Flow}
@return [Array] irrelevant @api private
# File lib/linearly/flow.rb, line 124 def build @steps.each(&method(:process)) [@inputs, @outputs].map(&:freeze) end
process(step)
click to toggle source
Process a single step
@param step [Step]
@return [Hash] irrelevant @api private
# File lib/linearly/flow.rb, line 135 def process(step) step.inputs.each do |key, val| @inputs[key] = val unless @inputs.key?(key) || @outputs.key?(key) end @outputs.merge!(step.outputs) end