Class: MandrillQueue::Adapters::ResqueAdapter

Inherits:
Object
  • Object
show all
Defined in:
lib/mandrill_queue/adapters/resque_adapter.rb

Instance Method Summary collapse

Instance Method Details

#check_for_scheduler!Object

Raises:

  • (RuntimeError)


16
17
18
19
# File 'lib/mandrill_queue/adapters/resque_adapter.rb', line 16

def check_for_scheduler!
  raise RuntimeError, "Please install resque-scheduler to allow scheduled jobs!" \
    unless ::Resque.respond_to?(:enqueue_in)
end

#enqueue_to(queue, klass, options, *args) ⇒ Object



4
5
6
7
8
9
10
11
12
13
14
# File 'lib/mandrill_queue/adapters/resque_adapter.rb', line 4

def enqueue_to(queue, klass, options, *args)
  if options.key?(:send_at)
    check_for_scheduler!
    Resque.enqueue_at_with_queue(queue, options[:send_at], klass, *args)
  elsif options.key?(:send_in)
    check_for_scheduler!
    Resque.enqueue_in_with_queue(queue, options[:send_in], klass, *args)
  else
    ::Resque.enqueue_to(queue, klass, *args)
  end
end