Class: ResqueSerial::AsyncJob
- Inherits:
-
Object
- Object
- ResqueSerial::AsyncJob
- Defined in:
- lib/resque-serial/async_job.rb
Class Method Summary collapse
-
.create(target, queue, *args) ⇒ Object
Add a job to queue.
- .enqueue_payload(target, queue, *args) ⇒ Object
- .perform(options) ⇒ Object
- .queue ⇒ Object
Class Method Details
.create(target, queue, *args) ⇒ Object
Add a job to queue. Queue name is a class module name
9 10 11 |
# File 'lib/resque-serial/async_job.rb', line 9 def create(target, queue, *args) Resque.enqueue self, enqueue_payload(target, queue, *args) end |
.enqueue_payload(target, queue, *args) ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/resque-serial/async_job.rb', line 13 def enqueue_payload(target, queue, *args) method = args.shift() = { class: target.class.to_s, id: target.id.to_s, method: method, args: args, } [:scope] = target.scope && !target.scope.is_a?(String) ? target.scope.id.to_s : target.scope [:timestamp] = target. if target. end |
.perform(options) ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/resque-serial/async_job.rb', line 27 def perform() .symbolize_keys! model = [:class].constantize.unscoped.find([:id]) model.scope = .delete(:scope) model. = .delete(:timestamp) model.send [:method], *[:args] end |
.queue ⇒ Object
4 5 6 |
# File 'lib/resque-serial/async_job.rb', line 4 def queue :sync end |