Module: DelayedCronJob::Backend::UpdatableCron
- Defined in:
- lib/delayed_cron_job/backend/updatable_cron.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.included(klass) ⇒ Object
5 6 7 8 |
# File 'lib/delayed_cron_job/backend/updatable_cron.rb', line 5 def self.included(klass) klass.send(:before_save, :set_next_run_at, :if => :cron_changed?) klass.attr_accessor :schedule_instead_of_destroy end |
Instance Method Details
#destroy ⇒ Object
17 18 19 |
# File 'lib/delayed_cron_job/backend/updatable_cron.rb', line 17 def destroy super unless schedule_instead_of_destroy end |
#schedule_next_run ⇒ Object
21 22 23 24 25 26 |
# File 'lib/delayed_cron_job/backend/updatable_cron.rb', line 21 def schedule_next_run self.attempts += 1 unlock set_next_run_at save! end |
#set_next_run_at ⇒ Object
10 11 12 13 14 15 |
# File 'lib/delayed_cron_job/backend/updatable_cron.rb', line 10 def set_next_run_at if cron.present? now = Delayed::Job.db_time_now self.run_at = Fugit::Cron.do_parse(cron).next_time(now).to_local_time end end |