Class: Hertz::Notification
- Inherits:
-
ActiveRecord::Base
- Object
- ActiveRecord::Base
- Hertz::Notification
- Defined in:
- app/models/hertz/notification.rb
Class Method Summary collapse
Instance Method Summary collapse
- #delivered_with?(courier) ⇒ Boolean
- #mark_as_read ⇒ Object
- #mark_as_unread ⇒ Object
- #mark_delivered_with(courier) ⇒ Object
- #read? ⇒ Boolean
- #unread? ⇒ Boolean
Class Method Details
.couriers ⇒ Object
16 17 18 |
# File 'app/models/hertz/notification.rb', line 16 def couriers @couriers ||= [] end |
Instance Method Details
#delivered_with?(courier) ⇒ Boolean
43 44 45 |
# File 'app/models/hertz/notification.rb', line 43 def delivered_with?(courier) deliveries.where(courier: courier).exists? end |
#mark_as_read ⇒ Object
35 36 37 |
# File 'app/models/hertz/notification.rb', line 35 def mark_as_read update read_at: Time.zone.now end |
#mark_as_unread ⇒ Object
39 40 41 |
# File 'app/models/hertz/notification.rb', line 39 def mark_as_unread update read_at: nil end |
#mark_delivered_with(courier) ⇒ Object
47 48 49 |
# File 'app/models/hertz/notification.rb', line 47 def mark_delivered_with(courier) deliveries.create(courier: courier) end |
#read? ⇒ Boolean
27 28 29 |
# File 'app/models/hertz/notification.rb', line 27 def read? read_at.present? end |
#unread? ⇒ Boolean
31 32 33 |
# File 'app/models/hertz/notification.rb', line 31 def unread? read_at.nil? end |