Module: Notifications::Model::ClassMethods

Defined in:
lib/notifications/model.rb

Instance Method Summary collapse

Instance Method Details

#read!(ids = []) ⇒ Object



42
43
44
45
# File 'lib/notifications/model.rb', line 42

def read!(ids = [])
  return if ids.blank?
  Notification.where(id: ids).update_all(read_at: Time.now)
end

#read_count(user) ⇒ Object



51
52
53
# File 'lib/notifications/model.rb', line 51

def read_count(user)
  Notification.where(user: user).read.count
end

#unread_count(user) ⇒ Object



47
48
49
# File 'lib/notifications/model.rb', line 47

def unread_count(user)
  Notification.where(user: user).unread.count
end