class Que::Metajob

Constants

SORT_KEYS

Attributes

job[R]

Public Class Methods

new(job) click to toggle source
# File lib/que/metajob.rb, line 12
def initialize(job)
  set_job(job)
end

Public Instance Methods

<=>(other) click to toggle source
# File lib/que/metajob.rb, line 28
def <=>(other)
  k1 = job
  k2 = other.job

  SORT_KEYS.each do |key|
    value1 = k1.fetch(key)
    value2 = k2.fetch(key)

    return -1 if value1 < value2
    return  1 if value1 > value2
  end

  0
end
id() click to toggle source
# File lib/que/metajob.rb, line 24
def id
  job.fetch(:id)
end
priority_sufficient?(threshold) click to toggle source
# File lib/que/metajob.rb, line 43
def priority_sufficient?(threshold)
  threshold.nil? || job.fetch(:priority) <= threshold
end
set_job(job) click to toggle source
# File lib/que/metajob.rb, line 16
def set_job(job)
  if (run_at = job.fetch(:run_at)).is_a?(Time)
    job[:run_at] = run_at.utc.iso8601(6)
  end

  @job = job
end