Sha256: b3580f4c0d50f4e15d1fb99617fc62ff95e6a63dd90b41cc9bb6dd11ce81a4bd
Contents?: true
Size: 866 Bytes
Versions: 33
Compression:
Stored size: 866 Bytes
Contents
# frozen_string_literal: true module Delayed module Jobs # # Single execution of a Job # class Run include StandardModel # # Fields # field :name, type: String field :locked_at, type: Time field :locked_by, type: String field :duration, type: Float, default: 0 # # Relationships # belongs_to :worker, class_name: 'Delayed::Jobs::Worker' # # Validations # validates :name, presence: true validates :locked_at, presence: true validates :duration, numericality: { greater_than_or_equal_to: 0 } # # Callbacks # before_validation :record_duration # # Finish execution # def record_duration self.duration = duration.zero? ? Time.now.utc - locked_at : duration end end end end
Version data entries
33 entries across 33 versions & 1 rubygems