Class: Notification

Inherits:
ActiveRecord::Base
  • Object
show all
Defined in:
app/models/notification.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#mail_paramsObject

Returns the value of attribute mail_params.



7
8
9
# File 'app/models/notification.rb', line 7

def mail_params
  @mail_params
end

Class Method Details

.create_notification(notification_type_name, user, mail_params = {}) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'app/models/notification.rb', line 13

def self.create_notification(notification_type_name, user, mail_params = {})
  if (nt = find_notification notification_type_name)
    create! user: user,
      project: mail_params[:project],
      backer: mail_params[:backer],
      project_update: mail_params[:update],
      notification_type: nt,
      mail_params: mail_params
  end
end

.create_notification_once(notification_type_name, user, filter, mail_params = {}) ⇒ Object



9
10
11
# File 'app/models/notification.rb', line 9

def self.create_notification_once(notification_type_name, user, filter, mail_params = {})
  create_notification(notification_type_name, user, mail_params) if self.where(filter.merge(notification_type_id: find_notification(notification_type_name))).empty?
end

Instance Method Details

#send_emailObject



24
25
26
27
28
29
# File 'app/models/notification.rb', line 24

def send_email
  unless dismissed
    NotificationsMailer.notify(self).deliver
    self.update_attributes dismissed: true
  end
end