Class: Plutonium::Interaction::Concerns::WorkflowDSL::WorkflowBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/plutonium/interaction/concerns/workflow_dsl.rb

Overview

Helper class for building workflows.

Instance Method Summary collapse

Constructor Details

#initialize(use_case_class) ⇒ WorkflowBuilder

Returns a new instance of WorkflowBuilder.

Parameters:

  • use_case_class (Class)

    The interaction class where the workflow is being defined.



46
47
48
# File 'lib/plutonium/interaction/concerns/workflow_dsl.rb', line 46

def initialize(use_case_class)
  @use_case_class = use_case_class
end

Instance Method Details

#step(name, use_case, if: nil) ⇒ Object

Adds a step to the workflow.

Parameters:

  • name (Symbol)

    The name of the step.

  • use_case (Class)

    The interaction class to be executed for this step.

  • if (Proc, nil) (defaults to: nil)

    An optional condition for executing the step.



55
56
57
58
59
60
61
# File 'lib/plutonium/interaction/concerns/workflow_dsl.rb', line 55

def step(name, use_case, if: nil)
  @use_case_class.workflow_steps << {
    name:,
    use_case:,
    condition: binding.local_variable_get(:if)
  }
end