module Teckel::Chain::ClassMethods

Public Instance Methods

call(input = nil) click to toggle source

The primary interface to call the chain with the given input.

@param input Any form of input the first steps input class can handle

@return [Teckel::Chain::Result] The result object wrapping

the result value, the success state and last executed step.
# File lib/teckel/chain.rb, line 47
def call(input = nil)
  default_settings = self.default_settings

  runner =
    if default_settings
      self.runner.new(self, default_settings)
    else
      self.runner.new(self)
    end

  if around
    around.call(runner, input)
  else
    runner.call(input)
  end
end
errors() click to toggle source

List of all possible errors @return [<Class>] List of all steps {Teckel::Operation.error}s

# File lib/teckel/chain.rb, line 34
def errors
  steps.each_with_object([]) do |step, m|
    err = step.operation.error
    m << err if err
  end
end
input() click to toggle source

The expected input for this chain @return [Class] The {Teckel::Operation.input} of the first step

# File lib/teckel/chain.rb, line 22
def input
  steps.first&.operation&.input
end
output() click to toggle source

The expected output for this chain @return [Class] The {Teckel::Operation.output} of the last step

# File lib/teckel/chain.rb, line 28
def output
  steps.last&.operation&.output
end
set(settings)
Alias for: with
with(settings) click to toggle source

@param settings [Hash{String,Symbol => Object}] Set settings for a step by it's name

# File lib/teckel/chain.rb, line 65
def with(settings)
  runner = self.runner.new(self, settings)
  if around
    ->(input) { around.call(runner, input) }
  else
    runner
  end
end
Also aliased as: set