Class: Philiprehberger::Pipe::Pipeline
- Inherits:
-
Object
- Object
- Philiprehberger::Pipe::Pipeline
- Defined in:
- lib/philiprehberger/pipe/pipeline.rb
Instance Attribute Summary collapse
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
- #add_step(step) ⇒ Object
- #execute(initial_value, error_handler: nil) ⇒ Object
-
#initialize ⇒ Pipeline
constructor
A new instance of Pipeline.
Constructor Details
#initialize ⇒ Pipeline
Returns a new instance of Pipeline.
8 9 10 |
# File 'lib/philiprehberger/pipe/pipeline.rb', line 8 def initialize @steps = [] end |
Instance Attribute Details
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
6 7 8 |
# File 'lib/philiprehberger/pipe/pipeline.rb', line 6 def steps @steps end |
Instance Method Details
#add_step(step) ⇒ Object
12 13 14 |
# File 'lib/philiprehberger/pipe/pipeline.rb', line 12 def add_step(step) @steps << step end |
#execute(initial_value, error_handler: nil) ⇒ Object
16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/philiprehberger/pipe/pipeline.rb', line 16 def execute(initial_value, error_handler: nil) @steps.reduce(initial_value) do |value, step| step.execute(value) end rescue Halted => e e.value rescue StandardError => e raise unless error_handler error_handler.call(e) end |