Class: WorkflowRb::WorkflowBuilder
- Inherits:
-
Object
- Object
- WorkflowRb::WorkflowBuilder
- Defined in:
- lib/workflow_rb/services/workflow_builder.rb
Instance Attribute Summary collapse
-
#initial_step ⇒ Object
Returns the value of attribute initial_step.
-
#steps ⇒ Object
Returns the value of attribute steps.
Instance Method Summary collapse
- #add_step(step) ⇒ Object
- #build(id, version, data_class) ⇒ Object
-
#initialize ⇒ WorkflowBuilder
constructor
A new instance of WorkflowBuilder.
- #start_step(&body) ⇒ Object
- #start_with(body, &setup) ⇒ Object
Constructor Details
#initialize ⇒ WorkflowBuilder
Returns a new instance of WorkflowBuilder.
9 10 11 |
# File 'lib/workflow_rb/services/workflow_builder.rb', line 9 def initialize @steps = [] end |
Instance Attribute Details
#initial_step ⇒ Object
Returns the value of attribute initial_step.
6 7 8 |
# File 'lib/workflow_rb/services/workflow_builder.rb', line 6 def initial_step @initial_step end |
#steps ⇒ Object
Returns the value of attribute steps.
7 8 9 |
# File 'lib/workflow_rb/services/workflow_builder.rb', line 7 def steps @steps end |
Instance Method Details
#add_step(step) ⇒ Object
23 24 25 26 |
# File 'lib/workflow_rb/services/workflow_builder.rb', line 23 def add_step(step) step.id = @steps.length @steps << step end |
#build(id, version, data_class) ⇒ Object
13 14 15 16 17 18 19 20 21 |
# File 'lib/workflow_rb/services/workflow_builder.rb', line 13 def build(id, version, data_class) result = WorkflowDefinition.new result.id = id result.version = version result.data_class = data_class result.steps = @steps result.initial_step = @initial_step result end |
#start_step(&body) ⇒ Object
45 46 47 |
# File 'lib/workflow_rb/services/workflow_builder.rb', line 45 def start_step(&body) start_with(body) end |
#start_with(body, &setup) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 |
# File 'lib/workflow_rb/services/workflow_builder.rb', line 28 def start_with(body, &setup) new_step = WorkflowStep.new new_step.body = body if body.kind_of?(Class) new_step.name = body.name end add_step(new_step) @initial_step = new_step.id new_builder = StepBuilder.new(self, new_step) if setup setup.call(new_builder) end new_builder end |