Module: Noticed::Model

Extended by:
ActiveSupport::Concern
Defined in:
lib/noticed/model.rb

Defined Under Namespace

Modules: ClassMethods

Instance Method Summary collapse

Instance Method Details

#mark_as_read!Object



41
42
43
# File 'lib/noticed/model.rb', line 41

def mark_as_read!
  update(read_at: Time.current)
end

#read?Boolean

Returns:

  • (Boolean)


49
50
51
# File 'lib/noticed/model.rb', line 49

def read?
  read_at?
end

#to_notificationObject

Rehydrate the database notification into the Notification object for rendering



33
34
35
36
37
38
39
# File 'lib/noticed/model.rb', line 33

def to_notification
  @_notification ||= begin
    instance = type.constantize.with(params)
    instance.record = self
    instance
  end
end

#unread?Boolean

Returns:

  • (Boolean)


45
46
47
# File 'lib/noticed/model.rb', line 45

def unread?
  !read?
end