Created
June 23, 2009 13:07
-
-
Save atnan/134520 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Job < ActiveRecord::Base | |
STATUS_READY, STATUS_IN_PROGRESS, STATUS_DONE = 1, 2, 3 | |
def self.fetch(pid) | |
update_all( | |
{ :status => STATUS_IN_PROGRESS, | |
:pid => pid }, | |
{ :status => STATUS_READY }, | |
{ :limit => 1, | |
:order => 'created_at asc' }) | |
find_by_status_and_pid STATUS_IN_PROGRESS, pid | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment