Permalink
Browse files

Refactored before_save, so that it's compatible with rails 3.

  • Loading branch information...
1 parent d848ae2 commit bcd8d72bd1d2103ebef5735da085a325f35278e3 @fredwu fredwu committed with bkeepers Mar 25, 2010
Showing with 3 additions and 5 deletions.
  1. +2 −0 lib/delayed/backend/active_record.rb
  2. +1 −1 lib/delayed/backend/base.rb
  3. +0 −4 lib/delayed/backend/mongo_mapper.rb
@@ -22,6 +22,8 @@ module ActiveRecord
class Job < ::ActiveRecord::Base
include Delayed::Backend::Base
set_table_name :delayed_jobs
+
+ before_save :set_default_run_at
named_scope :ready_to_run, lambda {|worker_name, max_run_time|
{:conditions => ['(run_at <= ? AND (locked_at IS NULL OR locked_at < ?) OR locked_by = ?) AND failed_at IS NULL', db_time_now, db_time_now - max_run_time, worker_name]}
@@ -97,7 +97,7 @@ def attempt_to_load(klass)
protected
- def before_save
+ def set_default_run_at
self.run_at ||= self.class.db_time_now
end
@@ -104,10 +104,6 @@ def self.make_date(date_or_seconds)
def make_date(date)
self.class.make_date(date)
end
-
- def set_default_run_at
- self.run_at ||= self.class.db_time_now
- end
end
end
end

0 comments on commit bcd8d72

Please sign in to comment.