Class: CMDx::Pipeline

Inherits:
Object
  • Object
show all
Defined in:
lib/cmdx/pipeline.rb

Overview

Executes workflows by processing task groups with conditional logic and breakpoint handling. The Pipeline class manages the execution flow of workflow tasks, evaluating conditions and handling breakpoints that can interrupt execution at specific task statuses.

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(workflow) ⇒ Pipeline

Returns A new pipeline instance.

Examples:

pipeline = Pipeline.new(my_workflow)

Parameters:

  • workflow (Workflow)

    The workflow to execute



27
28
29
# File 'lib/cmdx/pipeline.rb', line 27

def initialize(workflow)
  @workflow = workflow
end

Instance Attribute Details

#workflowWorkflow (readonly)

Returns the workflow being executed by this pipeline.

Examples:

pipeline.workflow.context[:status] # => "processing"

Returns:



17
18
19
# File 'lib/cmdx/pipeline.rb', line 17

def workflow
  @workflow
end

Class Method Details

.execute(workflow) ⇒ void

This method returns an undefined value.

Executes a workflow using a new pipeline instance.

Examples:

Pipeline.execute(my_workflow)

Parameters:

  • workflow (Workflow)

    The workflow to execute



41
42
43
# File 'lib/cmdx/pipeline.rb', line 41

def self.execute(workflow)
  new(workflow).execute
end

Instance Method Details

#executevoid

This method returns an undefined value.

Executes the workflow by processing all task groups in sequence. Each group is evaluated against its conditions, and breakpoints are checked after each task execution to determine if workflow should continue or halt.

Examples:

pipeline = Pipeline.new(my_workflow)
pipeline.execute


56
57
58
59
60
61
62
63
64
65
66
67
# File 'lib/cmdx/pipeline.rb', line 56

def execute
  workflow.class.pipeline.each do |group|
    next unless Utils::Condition.evaluate(workflow, group.options)

    breakpoints = group.options[:breakpoints] ||
                  workflow.class.settings[:breakpoints] ||
                  workflow.class.settings[:workflow_breakpoints]
    breakpoints = Array(breakpoints).map(&:to_s).uniq

    execute_group_tasks(group, breakpoints)
  end
end