Module: Noticed::Model
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/noticed/model.rb
Defined Under Namespace
Modules: ClassMethods
Instance Method Summary collapse
- #mark_as_read! ⇒ 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
30 31 32 |
# File 'lib/noticed/model.rb', line 30 def mark_as_read! update(read_at: Time.current) end |
#read? ⇒ Boolean
38 39 40 |
# File 'lib/noticed/model.rb', line 38 def read? read_at? end |
#to_notification ⇒ Object
Rehydrate the database notification into the Notification object for rendering
22 23 24 25 26 27 28 |
# File 'lib/noticed/model.rb', line 22 def to_notification @_notification ||= begin instance = type.constantize.with(params) instance.record = self instance end end |
#unread? ⇒ Boolean
34 35 36 |
# File 'lib/noticed/model.rb', line 34 def unread? !read? end |