Module: Plutonium::Interaction::Concerns::WorkflowDSL
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/plutonium/interaction/concerns/workflow_dsl.rb
Overview
DO NOT USE
Provides a Domain Specific Language (DSL) for defining workflows in interactions.
This module allows interactions to define a series of steps that can be executed in sequence, with optional conditions for each step.
Defined Under Namespace
Classes: WorkflowBuilder
Instance Method Summary collapse
-
#execute_workflow(context = {}) ⇒ Plutonium::Interaction::Outcome
Executes the defined workflow.
Instance Method Details
#execute_workflow(context = {}) ⇒ Plutonium::Interaction::Outcome
Executes the defined workflow.
68 69 70 71 72 73 74 75 76 77 78 |
# File 'lib/plutonium/interaction/concerns/workflow_dsl.rb', line 68 def execute_workflow(context = {}) self.class.workflow_steps.reduce(Success.new(context)) do |result, step| result.and_then do |ctx| if step[:condition].nil? || instance_exec(ctx, &step[:condition]) step[:use_case].call(context: ctx).map { |outcome| ctx[step[:name]] = outcome } else Success.new(ctx) end end end end |