class Roqua::Scheduling::Schedule
Constants
- BEGINNING_OF_EVERY_DAY
- BEGINNING_OF_EVERY_HOUR
Attributes
Public Class Methods
Source
# File lib/roqua/scheduling/schedule.rb, line 22 def self.current_schedule @schedule ||= Roqua::Scheduling::Schedule.new end
Source
# File lib/roqua/scheduling/schedule.rb, line 15 def self.setup @schedule = Roqua::Scheduling::Schedule.new.tap do |new_schedule| yield(new_schedule) new_schedule.initialize_cronjob_table end end
Public Instance Methods
Source
# File lib/roqua/scheduling/schedule.rb, line 11 def add_task(name, options, &block) @tasks[name] = Roqua::Scheduling::Task.new(name, options, block) end
Source
# File lib/roqua/scheduling/schedule.rb, line 26 def initialize_cronjob_table Roqua::Scheduling::CronJob.where('name NOT IN (?)', tasks.values.map(&:name)).delete_all tasks.each_value do |task| cron_job = Roqua::Scheduling::CronJob.find_or_initialize_by(name: task.name) cron_job.update next_run_at: task.next_run_at unless cron_job.persisted? end end