Sha256: a9d754eba7d7c7be8f0de0d97f75b78dffdac6300114aba92814f2e323e73e00

Contents?: true

Size: 575 Bytes

Versions: 4

Compression:

Stored size: 575 Bytes

Contents

module Notifiable
  class Notification < ActiveRecord::Base

    validates :level, :presence => true
    validates :header, :presence => true
    validates :message, :presence => true
    validates :expires, :presence => true
  
    named_scope :global,   :conditions => {:notifiable_id => nil}
    named_scope :viewable, lambda { {:conditions => ["dismissed = ? AND expires > ?", false, Time.now]} }

    belongs_to :notifiable, :polymorphic => true

    def viewable?
      !dismissed? && !expired?
    end

    def expired?
      Time.now > expires
    end
    
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
notifiable-0.0.4 app/models/notifiable/notification.rb
notifiable-0.0.3 app/models/notifiable/notification.rb
notifiable-0.0.2 app/models/notifiable/notification.rb
notifiable-0.0.1 app/models/notifiable/notification.rb