Class: Teckel::Chain::Runner
- Inherits:
-
Object
- Object
- Teckel::Chain::Runner
- Defined in:
- lib/teckel/chain.rb
Overview
The default implementation for executing a Teckel::Chain
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
-
#call(input) ⇒ Teckel::Result, Teckel::Chain::StepFailure
Run steps.
-
#initialize(steps) ⇒ Runner
constructor
A new instance of Runner.
Constructor Details
#initialize(steps) ⇒ Runner
Returns a new instance of Runner.
220 221 222 |
# File 'lib/teckel/chain.rb', line 220 def initialize(steps) @steps = steps end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
223 224 225 |
# File 'lib/teckel/chain.rb', line 223 def steps @steps end |
Instance Method Details
#call(input) ⇒ Teckel::Result, Teckel::Chain::StepFailure
Run steps
232 233 234 235 236 237 238 239 240 241 242 243 244 |
# File 'lib/teckel/chain.rb', line 232 def call(input) last_result = input failed = nil steps.each do |(name, step)| last_result = step.call(last_result) if last_result.failure? failed = StepFailure.new(step, name, last_result) break end end failed || last_result end |