mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
35 lines
No EOL
733 B
Ruby
35 lines
No EOL
733 B
Ruby
require 'resque'
|
|
require 'active_support/core_ext/enumerable'
|
|
require 'active_support/core_ext/array/access'
|
|
|
|
module ActiveJob
|
|
module QueueAdapters
|
|
class ResqueAdapter
|
|
class << self
|
|
def queue(job, *args)
|
|
Resque.enqueue *JobWrapper.wrap(job, args)
|
|
end
|
|
end
|
|
|
|
class JobWrapper
|
|
class << self
|
|
def wrap(job, args)
|
|
[ new(job), *args.prepend(job) ]
|
|
end
|
|
|
|
def perform(job_name, *args)
|
|
job_name.constantize.new.perform *Parameters.deserialize(args)
|
|
end
|
|
end
|
|
|
|
def initialize(job)
|
|
@queue = job.queue_name
|
|
end
|
|
|
|
def to_s
|
|
self.class.to_s
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end |