Sha256: c9c8e713f3663775e5415e1e12254761322cc445d50378ad6213417c8e54e11f

Contents?: true

Size: 526 Bytes

Versions: 5

Compression:

Stored size: 526 Bytes

Contents

module IntegrationPal
  class Job < ApplicationRecord
    include IntegrationPal::Statusable

    store :job_params, coder: Hash

    belongs_to :worker
    has_many :tasks

    validates :worker, presence: true

    def queue_job
      raise 'Cannot start a non persisted job' unless self.persisted?
      worker.job_class.perform_later(self.id)
    end

    def start
      self.update_attributes(status: IN_PROGRESS_STATUS, started_at: Time.zone.now, job_params: self.job_params.merge(worker.settings))
    end

  end

end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
integration_pal-0.2.3 app/models/integration_pal/job.rb
integration_pal-0.2.2 app/models/integration_pal/job.rb
integration_pal-0.2.1 app/models/integration_pal/job.rb
integration_pal-0.2.0 app/models/integration_pal/job.rb
integration_pal-0.1.6 app/models/integration_pal/job.rb