module SidekiqSchedulable::Schedule

Public Class Methods

enqueue(schedule, last_run = nil) click to toggle source
# File lib/sidekiq_schedulable/schedule.rb, line 5
def self.enqueue(schedule, last_run = nil)
  return if schedule[:crons].empty?

  worker = schedule[:worker]
  schedule[:crons].each do |cron|
    time = next_time(cron)
    if schedule[:options][:last_run]
      last_time = last_run || last_time(cron)
      worker.perform_at(time, last_time.to_f)
    else
      worker.perform_at(time)
    end
  end
end
last_time(schedule) click to toggle source
# File lib/sidekiq_schedulable/schedule.rb, line 24
def self.last_time(schedule)
  CronParser.new(schedule).last(Time.now)
end
next_time(schedule) click to toggle source
# File lib/sidekiq_schedulable/schedule.rb, line 20
def self.next_time(schedule)
  CronParser.new(schedule).next(Time.now)
end