lib/sucker_punch/backgroundable/backgroundable.rb in sucker_punch-backgroundable-0.1.0 vs lib/sucker_punch/backgroundable/backgroundable.rb in sucker_punch-backgroundable-0.2.0

- old
+ new

@@ -108,11 +108,12 @@ options = @__backgroundable_methods[method][:options] (singleton_method ? singleton : self).class_eval do define_method async_method do |*args| # run sucker punch job asynchronously - Job.new.async.perform(self, sync_method, args, options) +# Job.new.async.perform(self, sync_method, args, options) + JobRunner.new(self, sync_method, args, options).run end end code = singleton_method ? "class << self" : "" code << %Q{ @@ -140,14 +141,10 @@ end def method_missing(method, *args, &block) @receiver.method_missing(method, *args, &block) unless @receiver.respond_to?(method) raise ArgumentError.new("Backgrounding a method with a block argument is not supported.") if block_given? - if @seconds > 0 - Job.new.async.later(@seconds, @receiver, method, args, @options) - else - Job.new.async.perform(@receiver, method, args, @options) - end + JobRunner.new(@receiver, method, args, @options).run(@seconds) end end end \ No newline at end of file