lib/rufus/sc/jobs.rb in rufus-scheduler-2.0.1 vs lib/rufus/sc/jobs.rb in rufus-scheduler-2.0.2

- old
+ new

@@ -31,11 +31,11 @@ # class Job # A reference to the scheduler owning this job # - attr_reader :scheduler + attr_accessor :scheduler # The initial, raw, scheduling info (at / in / every / cron) # attr_reader :t @@ -125,18 +125,12 @@ @job_thread = Thread.current begin - #args = prepare_args - #@block.call(*args) + trigger_block - #@block.call(self) - - @block.respond_to?(:call) ? - @block.call(self) : @block.trigger(@params) - @job_thread = nil rescue Exception => e @scheduler.handle_exception(self, e) @@ -154,9 +148,18 @@ @job_thread.raise(Rufus::Scheduler::TimeOutError) \ if @job_thread and @job_thread.alive? end end + end + + # Simply encapsulating the block#call/trigger operation, for easy + # override. + # + def trigger_block + + @block.respond_to?(:call) ? + @block.call(self) : @block.trigger(@params.merge(:job => self)) end # Unschedules this job. # def unschedule