Sha256: b4f8a5d136ca1229f15850ea371a3232cffabf8ae3515137efd91b22d2d953ab
Contents?: true
Size: 1.03 KB
Versions: 5
Compression:
Stored size: 1.03 KB
Contents
module Extface class Job < ActiveRecord::Base belongs_to :device, inverse_of: :jobs scope :active, ->{ where(arel_table[:completed_at].eq(nil).and(arel_table[:failed_at].eq(nil))) } def complete! self.completed_at = Time.now save! notify("Job #{self.id} completed!") end def completed? !!completed_at end def connected! unless connected? self.connected_at = Time.now save! notify("Job #{self.id} device connected!") end end def connected? !!connected_at? end def failed!(message) self.error = message self.failed_at = Time.now save! notify(message) notify("Job #{self.id} failed!") end def failed? !!failed_at end def notify(message) Extface.redis_block do |r| r.publish(self.id, message) end end def rpush(buffer) Extface.redis_block do |r| r.rpush self.id, buffer end end end end
Version data entries
5 entries across 5 versions & 1 rubygems