Sha256: 2d7f75407b33cc3856d63faca7212c5e063c3fbcdf2ac1d068852bc765a7973b
Contents?: true
Size: 815 Bytes
Versions: 35
Compression:
Stored size: 815 Bytes
Contents
class Downtime include Mongoid::Document include Mongoid::Timestamps field :message, type: String field :start_time, type: DateTime field :end_time, type: DateTime belongs_to :artefact validates_presence_of :message, :start_time, :end_time, :artefact validate :end_time_is_in_future, on: :create validate :start_time_precedes_end_time def self.for(artefact) where(artefact_id: artefact.id).first end def publicise? Time.zone.now.between?(start_time.yesterday.at_midnight, end_time) end private def end_time_is_in_future errors.add(:end_time, "must be in the future") if end_time && ! end_time.future? end def start_time_precedes_end_time errors.add(:start_time, "must be earlier than end time") if start_time && end_time && start_time >= end_time end end
Version data entries
35 entries across 35 versions & 1 rubygems