Class: Teckel::Chain::Runner

Inherits:
Object
  • Object
show all
Defined in:
lib/teckel/chain/runner.rb

Overview

The default implementation for executing a Teckel::Chain

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(chain, settings = UNDEFINED) ⇒ Runner

Returns a new instance of Runner.



15
16
17
# File 'lib/teckel/chain/runner.rb', line 15

def initialize(chain, settings = UNDEFINED)
  @chain, @settings = chain, settings
end

Instance Attribute Details

#chainObject (readonly)

Returns the value of attribute chain.



18
19
20
# File 'lib/teckel/chain/runner.rb', line 18

def chain
  @chain
end

#settingsObject (readonly)

Returns the value of attribute settings.



18
19
20
# File 'lib/teckel/chain/runner.rb', line 18

def settings
  @settings
end

Instance Method Details

#call(input = nil) ⇒ Teckel::Chain::Result

Run steps

Parameters:

  • input (defaults to: nil)

    Any form of input the first steps input class can handle

Returns:



26
27
28
29
# File 'lib/teckel/chain/runner.rb', line 26

def call(input = nil)
  step_result = run(input)
  chain.result_constructor.call(*step_result)
end

#stepsObject



31
32
33
# File 'lib/teckel/chain/runner.rb', line 31

def steps
  settings == UNDEFINED ? chain.steps : steps_with_settings
end