lib/rufus/scheduler.rb in rufus-scheduler-3.2.1 vs lib/rufus/scheduler.rb in rufus-scheduler-3.2.2
- old
+ new
@@ -37,11 +37,11 @@
require 'rufus/scheduler/jobs'
require 'rufus/scheduler/cronline'
require 'rufus/scheduler/job_array'
require 'rufus/scheduler/locks'
- VERSION = '3.2.1'
+ VERSION = '3.2.2'
#
# A common error class for rufus-scheduler
#
class Error < StandardError; end
@@ -250,10 +250,13 @@
do_schedule(:cron, cronline, callable, opts, true, block)
end
def schedule(arg, callable=nil, opts={}, &block)
+ callable, opts = nil, callable if callable.is_a?(Hash)
+ opts = opts.dup
+
opts[:_t] = Scheduler.parse(arg, opts)
case opts[:_t]
when CronLine then schedule_cron(arg, callable, opts, &block)
when Time then schedule_at(arg, callable, opts, &block)
@@ -261,10 +264,13 @@
end
end
def repeat(arg, callable=nil, opts={}, &block)
+ callable, opts = nil, callable if callable.is_a?(Hash)
+ opts = opts.dup
+
opts[:_t] = Scheduler.parse(arg, opts)
case opts[:_t]
when CronLine then schedule_cron(arg, callable, opts, &block)
else schedule_every(arg, callable, opts, &block)
@@ -607,12 +613,14 @@
def do_schedule(job_type, t, callable, opts, return_job_instance, block)
fail NotRunningError.new(
'cannot schedule, scheduler is down or shutting down'
- ) if @started_at == nil
+ ) if @started_at.nil?
callable, opts = nil, callable if callable.is_a?(Hash)
+ opts = opts.dup unless opts.has_key?(:_t)
+
return_job_instance ||= opts[:job]
job_class =
case job_type
when :once