lib/rufus/scheduler/jobs.rb in rufus-scheduler-3.0.2 vs lib/rufus/scheduler/jobs.rb in rufus-scheduler-3.0.3
- old
+ new
@@ -112,11 +112,13 @@
set_next_time(false, time)
return if opts[:overlap] == false && running?
- r = callback(:pre, time)
+ r =
+ callback(:confirm_lock, time) &&
+ callback(:on_pre_trigger, time)
return if r == false
if opts[:blocking]
do_trigger(time)
@@ -181,19 +183,18 @@
#
# might be necessary at some point
protected
- def callback(position, time)
+ def callback(meth, time)
- name = position == :pre ? :on_pre_trigger : :on_post_trigger
+ return true unless @scheduler.respond_to?(meth)
- return unless @scheduler.respond_to?(name)
+ arity = @scheduler.method(meth).arity
+ args = [ self, time ][0, (arity < 0 ? 2 : arity)]
- args = @scheduler.method(name).arity < 2 ? [ self ] : [ self, time ]
-
- @scheduler.send(name, *args)
+ @scheduler.send(meth, *args)
end
def compute_timeout
if to = @opts[:timeout]
@@ -241,10 +242,10 @@
def post_trigger(time)
set_next_time(true, time)
- callback(:post, time)
+ callback(:on_post_trigger, time)
end
def start_work_thread
thread =