Module: ActiveJob::Temporal::ChildWorkflowOptions

Defined in:
lib/activejob/temporal/child_workflow_options.rb

Constant Summary collapse

SUPPORTED_CONFIGURED_OPTIONS =
%i[priority queue tags].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#temporal_child_workflowsObject (readonly)

Returns the value of attribute temporal_child_workflows.



14
15
16
# File 'lib/activejob/temporal/child_workflow_options.rb', line 14

def temporal_child_workflows
  @temporal_child_workflows
end

Class Method Details

.normalize(child_workflows) ⇒ Object



16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/activejob/temporal/child_workflow_options.rb', line 16

def self.normalize(child_workflows)
  return nil if child_workflows.nil?

  unless child_workflows.is_a?(Array)
    raise ArgumentError, "child_workflows must be an Array of ActiveJob classes or configured jobs"
  end
  if child_workflows.empty?
    raise ArgumentError, "child_workflows must contain at least one ActiveJob class or configured job"
  end

  child_workflows.map { |child_workflow| normalize_job_class(child_workflow) }
end

Instance Method Details

#set(options = {}) ⇒ Object



88
89
90
91
92
93
94
95
96
97
# File 'lib/activejob/temporal/child_workflow_options.rb', line 88

def set(options = {})
  enqueue_options = options.dup
  normalized_children = if enqueue_options.key?(:child_workflows)
                          ChildWorkflowOptions.normalize(enqueue_options.delete(:child_workflows))
                        end

  super(enqueue_options).tap do
    @temporal_child_workflows = normalized_children if options.key?(:child_workflows)
  end
end