class Que::Scheduler::QueJobType

For jobs of type Que::Job

Public Instance Methods

enqueue() click to toggle source
# File lib/que/scheduler/to_enqueue.rb, line 66
def enqueue
  job_settings = to_h.slice(:queue, :priority, :run_at).compact
  job =
    if args.is_a?(Hash)
      job_class.enqueue(**args.merge(job_settings))
    else
      job_class.enqueue(*args, **job_settings)
    end

  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