Module: Mandate::ActiveJobQueuer
- Defined in:
- lib/mandate-rails/active_job_queuer.rb
Class Method Summary collapse
Instance Method Summary collapse
Class Method Details
.extended(base) ⇒ Object
5 6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mandate-rails/active_job_queuer.rb', line 5 def self.extended(base) class << base def queue_as(queue) @active_job_queue = queue end def active_job_queue @active_job_queue || :default end end end |
Instance Method Details
#defer(*args, wait: nil, **kwargs) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mandate-rails/active_job_queuer.rb', line 17 def defer(*args, wait: nil, **kwargs) # We need to convert the jobs to a hash before we serialize as there's no serialization # format for a job. We do this here to avoid cluttering the codebase with this logic. if (prereqs = kwargs.delete(:prereq_jobs)) prereqs.map! do |job| { job_id: job.provider_job_id, queue_name: job.queue_name } end kwargs[:prereq_jobs] = prereqs if prereqs.present? end MandateJob.set( queue: active_job_queue, wait: ).perform_later(self.name, *args, **kwargs) end |