Created
February 8, 2011 15:34
-
-
Save mediocretes/816591 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Simulation < ActiveRecord::Base | |
@queue = :simulation | |
@unique_jobs = true | |
@delayed_jobs = true | |
def simulate | |
Resque.enable_delay(:simulation) #call this elsewhere in a production app | |
Resque.enqueue(Simulation, {:_id => self.id, :delay_until => Time.now + 1800}) | |
end | |
def self.perform(options) | |
sim = Simulation.find options['id'] | |
sim.actually_simulate | |
end | |
def actually_simulate | |
sleep 5 | |
self.results = rand 100 + 1 | |
save | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment