Class: DevSuite::Workflow::Engine

Inherits:
Object
  • Object
show all
Defined in:
lib/dev_suite/workflow/engine.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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 = {}, **options)
  @steps = []
  @context = StepContext.new(initial_context, **options)
end

Instance Attribute Details

#contextObject (readonly)

Returns the value of attribute context.



6
7
8
# File 'lib/dev_suite/workflow/engine.rb', line 6

def context
  @context
end

#stepsObject (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

#executeObject

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