Class: WorkflowRb::OutcomeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/workflow_rb/services/workflow_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow_builder, outcome) ⇒ OutcomeBuilder

Returns a new instance of OutcomeBuilder.



144
145
146
147
# File 'lib/workflow_rb/services/workflow_builder.rb', line 144

def initialize(workflow_builder, outcome)
  @workflow_builder = workflow_builder
  @outcome = outcome
end

Instance Attribute Details

#outcomeObject

Returns the value of attribute outcome.



142
143
144
# File 'lib/workflow_rb/services/workflow_builder.rb', line 142

def outcome
  @outcome
end

Instance Method Details

#then(body, &setup) ⇒ Object



149
150
151
152
153
154
155
156
157
158
159
160
161
162
# File 'lib/workflow_rb/services/workflow_builder.rb', line 149

def then(body, &setup)
  new_step = WorkflowStep.new
  new_step.body = body

  @workflow_builder.add_step(new_step)
  new_builder = StepBuilder.new(@workflow_builder, new_step)

  if setup
    setup.call(new_builder)
  end

  @outcome.next_step = new_step.id
  new_builder
end

#then_step(&body) ⇒ Object



164
165
166
# File 'lib/workflow_rb/services/workflow_builder.rb', line 164

def then_step(&body)
  self.then(body)
end