lib/rufus/scheduler.rb in rufus-scheduler-3.8.2 vs lib/rufus/scheduler.rb in rufus-scheduler-3.9.0

- old
+ new

@@ -7,11 +7,11 @@ module Rufus; end class Rufus::Scheduler - VERSION = '3.8.2' + VERSION = '3.9.0' EoTime = ::EtOrbi::EoTime require 'rufus/scheduler/util' require 'rufus/scheduler/jobs_core' @@ -720,9 +720,17 @@ when :cron CronJob end job = job_class.new(self, t, opts, block || callable) + + if job.past? && (d = job.send(:discard_past?)) + fail ArgumentError.new( + "scheduling in the past and discard_past set to :fail" + ) if d == :fail + return + end + job.check_frequency @jobs.push(job) return_job_instance ? job : job.job_id