Module: Delayed::Backend::Base::ClassMethods

Defined in:
lib/delayed/backend/base.rb

Instance Method Summary collapse

Instance Method Details

#enqueue(*args) ⇒ Object

Add a job to the queue



13
14
15
16
17
18
19
20
21
22
# File 'lib/delayed/backend/base.rb', line 13

def enqueue(*args)
  object = args.shift
  unless object.respond_to?(:perform)
    raise ArgumentError, 'Cannot enqueue items which do not respond to perform'
  end
    
  priority = args.first || 0
  run_at   = args[1]
  self.create(:payload_object => object, :priority => priority.to_i, :run_at => run_at)
end