module ActiveJob::Cron::Schedulable

Attributes

last_occurrence[R]

Public Instance Methods

method_missing(meth, *args, &block) click to toggle source
Calls superclass method
# File lib/active_job/cron/schedulable.rb, line 25
def method_missing(meth, *args, &block)
  if IceCube::Rule.respond_to?(meth)
    rule = IceCube::Rule.send(meth, *args, &block)
    schedule.add_recurrence_rule(rule)
    rule
  elsif schedule.respond_to?(meth)
    schedule.send(meth, *args, &block)
  else
    super
  end
end
ready_to_perform?(time) click to toggle source
# File lib/active_job/cron/schedulable.rb, line 6
def ready_to_perform?(time)
  next_occurrence = schedule.next_occurrence(time).to_i
  # See IceCube's document about how #next_occurrence works
  if next_occurrence != last_occurrence
    @last_occurrence = next_occurrence
    true
  else
    false
  end
end
recurrence() { || ... } click to toggle source
# File lib/active_job/cron/schedulable.rb, line 21
def recurrence
  yield
end
schedule() click to toggle source
# File lib/active_job/cron/schedulable.rb, line 17
def schedule
  @schedule ||= IceCube::Schedule.new
end