Sha256: 8a26be537279faf2a1df453724f9d6ef2fd1eafd759b63f6ff30d2f61eb13b77

Contents?: true

Size: 708 Bytes

Versions: 8

Compression:

Stored size: 708 Bytes

Contents

# frozen_string_literal: true

require "active_record"

module AcidicJob
  class Key < ActiveRecord::Base
    RECOVERY_POINT_FINISHED = "FINISHED"

    self.table_name = "acidic_job_keys"

    serialize :error_object
    serialize :job_args
    serialize :workflow
    store :attr_accessors

    validates :idempotency_key, presence: true, uniqueness: { scope: %i[job_name job_args] }
    validates :job_name, presence: true
    validates :last_run_at, presence: true
    validates :recovery_point, presence: true

    def finished?
      recovery_point == RECOVERY_POINT_FINISHED
    end

    def succeeded?
      finished? && !failed?
    end

    def failed?
      error_object.present?
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
acidic_job-0.7.7 lib/acidic_job/key.rb
acidic_job-0.7.6 lib/acidic_job/key.rb
acidic_job-0.7.5 lib/acidic_job/key.rb
acidic_job-0.7.4 lib/acidic_job/key.rb
acidic_job-0.7.3 lib/acidic_job/key.rb
acidic_job-0.7.2 lib/acidic_job/key.rb
acidic_job-0.7.1 lib/acidic_job/key.rb
acidic_job-0.7.0 lib/acidic_job/key.rb