aboutsummaryrefslogtreecommitdiffstats
path: root/lib/active_job/queue_adapters/qu_adapter.rb
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@basecamp.com>2014-06-12 11:50:52 +0200
committerDavid Heinemeier Hansson <david@basecamp.com>2014-06-12 11:50:52 +0200
commit62c5ea58aa17e649235241a94b162c0059239983 (patch)
treebcabfe0727216ba16eb7e7878fb829bc456c22df /lib/active_job/queue_adapters/qu_adapter.rb
parent694b562080a7b1473d20c743877481e13d51c421 (diff)
parentb36d4da340fe81827601f9c192aefb2982cbcefb (diff)
downloadrails-62c5ea58aa17e649235241a94b162c0059239983.tar.gz
rails-62c5ea58aa17e649235241a94b162c0059239983.tar.bz2
rails-62c5ea58aa17e649235241a94b162c0059239983.zip
Merge pull request #86 from cristianbica/qu_adapter
Implemented :qu adapter
Diffstat (limited to 'lib/active_job/queue_adapters/qu_adapter.rb')
-rw-r--r--lib/active_job/queue_adapters/qu_adapter.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/active_job/queue_adapters/qu_adapter.rb b/lib/active_job/queue_adapters/qu_adapter.rb
new file mode 100644
index 0000000000..7e69229801
--- /dev/null
+++ b/lib/active_job/queue_adapters/qu_adapter.rb
@@ -0,0 +1,28 @@
+require 'qu'
+
+module ActiveJob
+ module QueueAdapters
+ class QuAdapter
+ class << self
+ def enqueue(job, *args)
+ Qu::Payload.new(klass: JobWrapper, args: [job, *args], queue: job.queue_name).push
+ end
+
+ def enqueue_at(job, timestamp, *args)
+ raise NotImplementedError
+ end
+ end
+
+ class JobWrapper < Qu::Job
+ def initialize(job, *args)
+ @job = job
+ @args = args
+ end
+
+ def perform
+ @job.new.execute *@args
+ end
+ end
+ end
+ end
+end