From 2ac1a021025ad4f5f85368b9a85dcf210e5797d6 Mon Sep 17 00:00:00 2001 From: Charlie Somerville Date: Mon, 19 May 2014 01:27:50 +1000 Subject: Clean up JobWrappers::ResqueWrapper.perform This is not only easier to read, but it'll also properly raise an ArgumentError rather than a NoMethodError when called with no arguments. It also allocates 4 fewer objects per call (8 down from 12), and is about 50% faster according to a quick benchmark. --- lib/active_job/job_wrappers/resque_wrapper.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/lib/active_job/job_wrappers/resque_wrapper.rb b/lib/active_job/job_wrappers/resque_wrapper.rb index c34ea99f3c..0db9cf144f 100644 --- a/lib/active_job/job_wrappers/resque_wrapper.rb +++ b/lib/active_job/job_wrappers/resque_wrapper.rb @@ -13,14 +13,8 @@ module ActiveJob [ new(job), *args.prepend(job) ] end - def perform(*args) - unwrapped_job = args.first.constantize - - if args.many? - unwrapped_job.perform *args.from(1) - else - unwrapped_job.perform - end + def perform(job_name, *args) + job_name.constantize.perform(*args) end end @@ -34,4 +28,4 @@ module ActiveJob end end end -end \ No newline at end of file +end -- cgit v1.2.3