Sha256: ad09b8f9ce87750372ab31d392cc666f099431a3cdea8948088c5ee76fd9f08a

Contents?: true

Size: 606 Bytes

Versions: 16

Compression:

Stored size: 606 Bytes

Contents

class Notification < ApplicationRecord
  belongs_to :user
  belongs_to :organization
  belongs_to :target, polymorphic: true, optional: true

  enum subject: %i(
    custom
    exam_authorization_request_updated
    exam_registration)

  scope :notified_users_ids_for, ->(target, organization=Organization.current) do
    where(target: target, organization: organization).pluck(:user_id)
  end

  def mark_as_read!
    update read: true
  end

  def self.create_and_notify_via_email!(args)
    create!(args).tap(&:notify_via_email!)
  end

  def notify_via_email!
    user.notify_via_email! self
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
mumuki-domain-9.23.0 app/models/notification.rb
mumuki-domain-9.22.1 app/models/notification.rb
mumuki-domain-9.22.0 app/models/notification.rb
mumuki-domain-9.21.0 app/models/notification.rb
mumuki-domain-9.20.0 app/models/notification.rb
mumuki-domain-9.19.0 app/models/notification.rb
mumuki-domain-9.18.0 app/models/notification.rb
mumuki-domain-9.17.0 app/models/notification.rb
mumuki-domain-9.16.0 app/models/notification.rb
mumuki-domain-9.15.0 app/models/notification.rb
mumuki-domain-9.14.1 app/models/notification.rb
mumuki-domain-9.14.0 app/models/notification.rb
mumuki-domain-9.13.1 app/models/notification.rb
mumuki-domain-9.13.0 app/models/notification.rb
mumuki-domain-9.12.0 app/models/notification.rb
mumuki-domain-9.11.0 app/models/notification.rb