module Noticed::Model
Public Instance Methods
mark_as_read!()
click to toggle source
# File lib/noticed/model.rb, line 18 def mark_as_read! update_all(read_at: Time.current, updated_at: Time.current) end
mark_as_unread!()
click to toggle source
# File lib/noticed/model.rb, line 22 def mark_as_unread! update_all(read_at: nil, updated_at: Time.current) end
noticed_coder()
click to toggle source
# File lib/noticed/model.rb, line 26 def noticed_coder return Noticed::TextCoder unless table_exists? case attribute_types["params"].type when :json, :jsonb Noticed::Coder else Noticed::TextCoder end rescue ActiveRecord::NoDatabaseError Noticed::TextCoder end
read?()
click to toggle source
# File lib/noticed/model.rb, line 61 def read? read_at? end
to_notification()
click to toggle source
Rehydrate the database notification into the Notification object for rendering
# File lib/noticed/model.rb, line 41 def to_notification @_notification ||= begin instance = type.constantize.with(params) instance.record = self instance end end
unread?()
click to toggle source
# File lib/noticed/model.rb, line 57 def unread? !read? end