Sha256: 1ec624534ff89fb10a403e90e7596c8defc61abc1a0e47d409ca89ed7afb6685

Contents?: true

Size: 656 Bytes

Versions: 2

Compression:

Stored size: 656 Bytes

Contents

class Wupee::Notification < ActiveRecord::Base
  belongs_to :receiver, polymorphic: true
  belongs_to :attached_object, polymorphic: true
  belongs_to :notification_type, class_name: "Wupee::NotificationType"

  validates :receiver, presence: true
  validates :notification_type, presence: true

  scope :read, -> { where(is_read: true) }
  scope :unread, -> { where(is_read: false) }
  scope :wanted, -> { where(is_wanted: true) }
  scope :unwanted, -> { where(is_wanted: false) }
  scope :ordered, -> { order(created_at: :desc) }

  def mark_as_read
    update_columns(is_read: true)
  end

  def mark_as_sent
    update_columns(is_sent: true)
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
wupee-2.0.0.beta2 app/models/wupee/notification.rb
wupee-2.0.0.beta1 app/models/wupee/notification.rb