Module: Resque::DelayedJob

Defined in:
lib/resque/delayed.rb

Instance Method Summary collapse

Instance Method Details

#before_create_with_delay(item, *args) ⇒ Object



12
13
14
# File 'lib/resque/delayed.rb', line 12

def before_create_with_delay(item, *args)
  item[:delay_until] = args[0][:delay_until]
end

#before_enqueue_with_delay(*args) ⇒ Object



3
4
5
6
7
8
9
10
# File 'lib/resque/delayed.rb', line 3

def before_enqueue_with_delay(*args)
  unless Resque.delayed_queue?(self)
    raise DelayedQueueError.new 'trying to insert a delayed job into a non-delayed queue' 
  end
  unless args[0].is_a?(Hash) && args[0].has_key?(:delay_until)
    raise DelayedQueueError.new 'trying to insert delayed job without delay_until'
  end
end

#before_pop_with_delay(query) ⇒ Object



16
17
18
# File 'lib/resque/delayed.rb', line 16

def before_pop_with_delay(query)
  query['delay_until'] = {'$lt' => Time.now } if delayed_queue?(queue)
end