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
45 46 47 |
# File 'lib/noticed/model.rb', line 45 def mark_as_read! update(read_at: Time.current) end |
#mark_as_unread! ⇒ Object
49 50 51 |
# File 'lib/noticed/model.rb', line 49 def mark_as_unread! update(read_at: nil) end |
#read? ⇒ Boolean
57 58 59 |
# File 'lib/noticed/model.rb', line 57 def read? read_at? end |
#to_notification ⇒ Object
Rehydrate the database notification into the Notification object for rendering
37 38 39 40 41 42 43 |
# File 'lib/noticed/model.rb', line 37 def to_notification @_notification ||= begin instance = type.constantize.with(params) instance.record = self instance end end |
#unread? ⇒ Boolean
53 54 55 |
# File 'lib/noticed/model.rb', line 53 def unread? !read? end |