Module: Noticed::Model
- Extended by:
- ActiveSupport::Concern
- Defined in:
- lib/noticed/model.rb
Constant Summary collapse
- DATABASE_ERROR_CLASS_NAMES =
lambda { classes = [ActiveRecord::NoDatabaseError] classes << ActiveRecord::ConnectionNotEstablished classes << Mysql2::Error if defined?(::Mysql2) classes << PG::ConnectionBad if defined?(::PG) classes }.call.freeze
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
60 61 62 |
# File 'lib/noticed/model.rb', line 60 def mark_as_read! update(read_at: Time.current) end |
#mark_as_unread! ⇒ Object
64 65 66 |
# File 'lib/noticed/model.rb', line 64 def mark_as_unread! update(read_at: nil) end |
#read? ⇒ Boolean
72 73 74 |
# File 'lib/noticed/model.rb', line 72 def read? read_at? end |
#to_notification ⇒ Object
Rehydrate the database notification into the Notification object for rendering
51 52 53 54 55 56 57 58 |
# File 'lib/noticed/model.rb', line 51 def to_notification @_notification ||= begin instance = type.constantize.with(params) instance.record = self instance.recipient = recipient instance end end |
#unread? ⇒ Boolean
68 69 70 |
# File 'lib/noticed/model.rb', line 68 def unread? !read? end |