Class: Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Notification
- Defined in:
- lib/generators/notifykit/templates/app/models/notification.rb
Instance Method Summary collapse
- #cancel ⇒ Object
- #cancelled? ⇒ Boolean
- #click ⇒ Object
- #deliver ⇒ Object
- #ignore ⇒ Object
- #read ⇒ Object
- #to_param ⇒ Object
- #unsubscribe ⇒ Object
Instance Method Details
#cancel ⇒ Object
34 35 36 37 |
# File 'lib/generators/notifykit/templates/app/models/notification.rb', line 34 def cancel return true if self.cancelled_at.present? self.update_attribute(:cancelled_at, Time.now) end |
#cancelled? ⇒ Boolean
39 40 41 |
# File 'lib/generators/notifykit/templates/app/models/notification.rb', line 39 def cancelled? self.cancelled_at.present? end |
#click ⇒ Object
14 15 16 17 18 19 |
# File 'lib/generators/notifykit/templates/app/models/notification.rb', line 14 def click return false if self.cancelled? self.click_count += 1 self.clicked_at ||= Time.now self.save end |
#deliver ⇒ Object
48 49 50 51 52 |
# File 'lib/generators/notifykit/templates/app/models/notification.rb', line 48 def deliver return if self.email_sent_at.present? || !self.deliver_via_email? NotificationsMailer.notify(self.id).deliver end |
#ignore ⇒ Object
28 29 30 31 32 |
# File 'lib/generators/notifykit/templates/app/models/notification.rb', line 28 def ignore return false if self.cancelled? self.ignored_at ||= Time.now self.save end |
#read ⇒ Object
21 22 23 24 25 26 |
# File 'lib/generators/notifykit/templates/app/models/notification.rb', line 21 def read return false if self.cancelled? self.read_count += 1 self.read_at ||= Time.now self.save end |
#to_param ⇒ Object
54 55 56 |
# File 'lib/generators/notifykit/templates/app/models/notification.rb', line 54 def to_param self.token end |
#unsubscribe ⇒ Object
43 44 45 46 |
# File 'lib/generators/notifykit/templates/app/models/notification.rb', line 43 def unsubscribe self.unsubscribed_at ||= Time.now self.save end |