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

Rbs:

  • (Workflow workflow) -> void



35
36
37
# File 'lib/cmdx/pipeline.rb', line 35

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:

Rbs:

  • @workflow: Workflow



25
26
27
# File 'lib/cmdx/pipeline.rb', line 25

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

Rbs:

  • (Workflow workflow) -> void



49
50
51
# File 'lib/cmdx/pipeline.rb', line 49

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

Rbs:

  • () -> void



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# File 'lib/cmdx/pipeline.rb', line 64

def execute
  default_breakpoints = Utils::Normalize.statuses(
    workflow.class.settings.breakpoints ||
    workflow.class.settings.workflow_breakpoints
  )

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

    breakpoints =
      if group.options.key?(:breakpoints)
        Utils::Normalize.statuses(group.options[:breakpoints])
      else
        default_breakpoints
      end

    execute_group_tasks(group, breakpoints)
  end
end