Class: Que::Scheduler::QueJobType

Inherits:
ToEnqueue
  • Object
show all
Defined in:
lib/que/scheduler/to_enqueue.rb

Overview

For jobs of type Que::Job

Instance Method Summary collapse

Methods inherited from ToEnqueue

active_job_defined?, active_job_version, active_job_version_supports_queues?, create, valid_job_class?

Instance Method Details

#enqueueObject



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# File 'lib/que/scheduler/to_enqueue.rb', line 64

def enqueue
  job_settings = to_h.slice(:queue, :priority, :run_at).compact
  job = Que::Scheduler::VersionSupport.enqueue_a_job(
    job_class,
    job_settings,
    args
  )

  return nil if job.nil? || !job # nil in Rails < 6.1, false after.

  # Now read the just inserted job back out of the DB to get the actual values that will
  # be used when the job is worked.
  values = Que::Scheduler::VersionSupport.job_attributes(job).slice(
    :args, :queue, :priority, :run_at, :job_class, :job_id
  )
  EnqueuedJobType.new(values)
end