Sha256: 85ffeee681b20525dc33c38ac8dc062b675b46dcde71cb45a3d5464892647ec4

Contents?: true

Size: 657 Bytes

Versions: 4

Compression:

Stored size: 657 Bytes

Contents

module Sidejobs
  class Job < ActiveRecord::Base

    STATUS = %w(pending processing failing complete)

    STATUS.each do |name|
      scope name, -> { where(status: name) }
      define_method "#{name}?" do
        status == name
      end
    end

    validates_presence_of :queue, :data, :status
    validates_presence_of :error, :failed_at, if: :failing?
    validates_presence_of :completed_at, if: :complete?
    validates_presence_of :processed_at, if: :processing?
    validates_inclusion_of :status, within: STATUS
    validates_numericality_of :priority, :attempts, only_integer: true

    def self.table_name
      'sidejobs'
    end

  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
sidejobs-5.1.0 lib/sidejobs/job.rb
sidejobs-4.0.0.2 lib/sidejobs/job.rb
sidejobs-4.0.0.1 lib/sidejobs/job.rb
sidejobs-4.0.0.0 lib/sidejobs/job.rb