Class: Lev::ActiveJob::Base

Inherits:
ActiveJob::Base
  • Object
show all
Defined in:
lib/lev/active_job.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.perform_later(routine_class, *args, &block) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/lev/active_job.rb', line 5

def self.perform_later(routine_class, *args, &block)
  queue_as routine_class.active_job_queue
  args.push(routine_class.to_s)

  # To enable tracking of this job's status, create a new Status object
  # and push it on to the arguments so that in `perform` it can be peeled
  # off and handed to the routine instance.  The Status UUID is returned
  # so that callers can track the status.
  status = Lev::Status.new
  status.queued!
  args.push(status.uuid)

  super(*args, &block)

  status.uuid
end

Instance Method Details

#perform(*args, &block) ⇒ Object



22
23
24
25
26
27
28
29
# File 'lib/lev/active_job.rb', line 22

def perform(*args, &block)
  # Pop arguments added by perform_later
  uuid = args.pop
  routine_class = Kernel.const_get(args.pop)

  routine_instance = routine_class.new(Lev::Status.new(uuid))
  routine_instance.call(*args, &block)
end