Module: ActiveJob::Multiq::ClassMethods

Defined in:
lib/activejob/multiq.rb

Instance Method Summary collapse

Instance Method Details

#queue_adapterObject

ActiveJob delegates to this method when enqueueing a job



14
15
16
17
18
19
20
# File 'lib/activejob/multiq.rb', line 14

def queue_adapter
  case @multiq_queue_adapter
  when nil then ActiveJob::Base.queue_adapter
  when Proc then @multiq_queue_adapter.call
  else @multiq_queue_adapter
  end
end

#queue_with(adapter_or_name = nil, options = {}, &block) ⇒ Object



22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/activejob/multiq.rb', line 22

def queue_with(adapter_or_name = nil, options = {}, &block)
  if adapter_or_name.nil? && !block_given?
    raise ArgumentError, "Must provide adapter or block"
  end

  return if options[:unless] && options[:unless].call
  return if options[:if] && !options[:if].call

  if block_given?
    @multiq_queue_adapter = block
    return
  end

  @multiq_queue_adapter = convert_adapter_name(adapter_or_name)

  if @multiq_queue_adapter.nil?
    raise ArgumentError, "#{adapter_or_name} is not a valid adapter"
  end
end