Sha256: 5493440414c97b3b28a56b781473aa5f5dfaefc4ef9af501e44ae83836d14757
Contents?: true
Size: 1.26 KB
Versions: 2
Compression:
Stored size: 1.26 KB
Contents
module Massive module Status extend ActiveSupport::Concern included do field :started_at, type: Time field :finished_at, type: Time field :failed_at, type: Time field :cancelled_at, type: Time field :last_error, type: String field :retries, type: Integer, default: 0 scope :started, ne(started_at: nil) scope :not_started, where(started_at: nil) scope :completed, ne(finished_at: nil) scope :not_completed, where(finished_at: nil) scope :failed, ne(failed_at: nil) scope :cancelled, ne(cancelled_at: nil) end def start! update_attributes(attributes_to_reset) end def started? !failed? && started_at? end def completed? !failed? && finished_at? end def failed? failed_at? end def enqueued? item = Resque.peek(self.class.queue) item.present? && (item["class"] == self.class.name) && (item["args"] == args_for_resque) end protected def attributes_to_reset { started_at: Time.now, finished_at: nil, failed_at: nil, cancelled_at: nil, retries: 0, last_error: nil } end def args_for_resque end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
massive-0.1.1 | lib/massive/status.rb |
massive-0.1.0 | lib/massive/status.rb |