Module: ActiveJob::Temporal::ChainOptions

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

Constant Summary collapse

SUPPORTED_CONFIGURED_OPTIONS =
%i[priority queue].freeze

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#temporal_chainObject (readonly)

Returns the value of attribute temporal_chain.



13
14
15
# File 'lib/activejob/temporal/chain_options.rb', line 13

def temporal_chain
  @temporal_chain
end

Class Method Details

.normalize(chain) ⇒ Object

Raises:

  • (ArgumentError)


15
16
17
18
19
20
21
22
# File 'lib/activejob/temporal/chain_options.rb', line 15

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

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

  chain.map { |job_class| normalize_job_class(job_class) }
end

Instance Method Details

#set(options = {}) ⇒ Object



71
72
73
74
75
76
77
78
# File 'lib/activejob/temporal/chain_options.rb', line 71

def set(options = {})
  enqueue_options = options.dup
  normalized_chain = ChainOptions.normalize(enqueue_options.delete(:chain)) if enqueue_options.key?(:chain)

  super(enqueue_options).tap do
    @temporal_chain = normalized_chain if options.key?(:chain)
  end
end