Class: DevSuite::Workflow::Engine
- Inherits:
-
Object
- Object
- DevSuite::Workflow::Engine
- Defined in:
- lib/dev_suite/workflow/engine.rb
Instance Attribute Summary collapse
-
#context ⇒ Object
readonly
Returns the value of attribute context.
-
#steps ⇒ Object
readonly
Returns the value of attribute steps.
Instance Method Summary collapse
-
#execute ⇒ Object
Execute the workflow.
-
#initialize(initial_context = {}, **options) ⇒ Engine
constructor
A new instance of Engine.
-
#step(step) ⇒ Object
Add steps to the engine.
Constructor Details
#initialize(initial_context = {}, **options) ⇒ Engine
Returns a new instance of Engine.
8 9 10 11 |
# File 'lib/dev_suite/workflow/engine.rb', line 8 def initialize(initial_context = {}, **) @steps = [] @context = StepContext.new(initial_context, **) end |
Instance Attribute Details
#context ⇒ Object (readonly)
Returns the value of attribute context.
6 7 8 |
# File 'lib/dev_suite/workflow/engine.rb', line 6 def context @context end |
#steps ⇒ Object (readonly)
Returns the value of attribute steps.
6 7 8 |
# File 'lib/dev_suite/workflow/engine.rb', line 6 def steps @steps end |
Instance Method Details
#execute ⇒ Object
Execute the workflow
20 21 22 23 24 |
# File 'lib/dev_suite/workflow/engine.rb', line 20 def execute @steps.each do |step| step.run(@context) end end |
#step(step) ⇒ Object
Add steps to the engine
14 15 16 17 |
# File 'lib/dev_suite/workflow/engine.rb', line 14 def step(step) @steps << step self # Return the current engine instance to support chaining end |