From eed52c8808fceb0004e488f77f0bc6904f7aaddf Mon Sep 17 00:00:00 2001 From: David Heinemeier Hansson Date: Sun, 18 May 2014 13:11:00 +0200 Subject: Add ResqueAdapter and provide test infrastructure for the now multiple adapters --- lib/active_job/base.rb | 7 +++++-- lib/active_job/queue_adapters/inline_queue.rb | 11 ----------- lib/active_job/queue_adapters/resque_adapter.rb | 13 +++++++++++++ 3 files changed, 18 insertions(+), 13 deletions(-) delete mode 100644 lib/active_job/queue_adapters/inline_queue.rb create mode 100644 lib/active_job/queue_adapters/resque_adapter.rb (limited to 'lib/active_job') diff --git a/lib/active_job/base.rb b/lib/active_job/base.rb index a404355026..e18c9d4309 100644 --- a/lib/active_job/base.rb +++ b/lib/active_job/base.rb @@ -1,10 +1,13 @@ -require 'active_job/queue_adapters/inline_queue' +require 'active_job/queue_adapters/inline_adapter' +require 'active_job/queue_adapters/resque_adapter' module ActiveJob class Base + cattr_accessor(:queue_adapter) { ActiveJob::QueueAdapters::InlineAdapter } + class << self def enqueue(*args) - ActiveJob::QueueAdapters::InlineQueue.queue self, *args + queue_adapter.queue self, *args end end end diff --git a/lib/active_job/queue_adapters/inline_queue.rb b/lib/active_job/queue_adapters/inline_queue.rb deleted file mode 100644 index dd80c6a5a3..0000000000 --- a/lib/active_job/queue_adapters/inline_queue.rb +++ /dev/null @@ -1,11 +0,0 @@ -module ActiveJob - module QueueAdapters - class InlineQueue - class << self - def queue(job, *args) - job.perform *args - end - end - end - end -end \ No newline at end of file diff --git a/lib/active_job/queue_adapters/resque_adapter.rb b/lib/active_job/queue_adapters/resque_adapter.rb new file mode 100644 index 0000000000..4155cd5bf9 --- /dev/null +++ b/lib/active_job/queue_adapters/resque_adapter.rb @@ -0,0 +1,13 @@ +require 'resque' + +module ActiveJob + module QueueAdapters + class ResqueAdapter + class << self + def queue(job, *args) + Resque.enqueue(job, *args) + end + end + end + end +end \ No newline at end of file -- cgit v1.2.3