Module: Noticed::Model
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/noticed/model.rb
Instance Method Summary collapse
- #mark_as_read! ⇒ Object
- #mark_as_unread! ⇒ Object
- #read? ⇒ Boolean
-
#to_notification ⇒ Object
Rehydrate the database notification into the Notification object for rendering.
- #unread? ⇒ Boolean
Instance Method Details
#mark_as_read! ⇒ Object
50 51 52 |
# File 'lib/noticed/model.rb', line 50 def mark_as_read! update(read_at: Time.current) end |
#mark_as_unread! ⇒ Object
54 55 56 |
# File 'lib/noticed/model.rb', line 54 def mark_as_unread! update(read_at: nil) end |
#read? ⇒ Boolean
62 63 64 |
# File 'lib/noticed/model.rb', line 62 def read? read_at? end |
#to_notification ⇒ Object
Rehydrate the database notification into the Notification object for rendering
41 42 43 44 45 46 47 48 |
# File 'lib/noticed/model.rb', line 41 def to_notification @_notification ||= begin instance = type.constantize.with(params) instance.record = self instance.recipient = recipient instance end end |
#unread? ⇒ Boolean
58 59 60 |
# File 'lib/noticed/model.rb', line 58 def unread? !read? end |