Skip to content

Instantly share code, notes, and snippets.

@coffeeaddict
Created May 25, 2010 14:15
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save coffeeaddict/413167 to your computer and use it in GitHub Desktop.
Save coffeeaddict/413167 to your computer and use it in GitHub Desktop.
Delayed Job scheduling
# make an alternative for send_later that accepts a run_at time
#
module Delayed
module MessageSending
def send_later_at(at, method, *args)
Delayed::Job.enqueue(
Delayed::PerformableMethod.new(self, method.to_sym, args),
0, #priority
at #run_at
)
end
end
end
# >> Time.now
# => Tue May 25 16:13:38 +0200 2010
# >> @model.send_later_at(5.minutes.from_now, :method)
# => #<Delayed::Job id: 2864, priority: 0, attempts: 0, handler: "--- !ruby/struct:Delayed::PerformableMethod \nobject...", last_error: nil, run_at: "2010-05-25 14:18:43", locked_at: nil, failed_at: nil, locked_by: nil, created_at: "2010-05-25 14:13:43", updated_at: "2010-05-25 14:13:43">
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment