Class: NotifyOn::Notification

Inherits:
ApplicationRecord show all
Includes:
EmailSupport, PusherSupport, StringInterpolation
Defined in:
app/models/notify_on/notification.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from PusherSupport

#push!, #pusher_attrs, #pusher_channel_name, #pusher_event_name, #pusher_recipient_active?, #pusher_sender_active?

Methods included from EmailSupport

#email_attachments, #email_from, #email_reply_to, #email_subject, #email_template, #send_email!, #should_save_email_id?

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(method_name, *args, &blk) ⇒ Object



71
72
73
74
# File 'app/models/notify_on/notification.rb', line 71

def method_missing(method_name, *args, &blk)
  return Hashie::Mash.new(options) if method_name.to_s == 'opts'
  super
end

Class Method Details

.mark_read_for(recipient, trigger) ⇒ Object

—————————————- Class Methods



48
49
50
51
# File 'app/models/notify_on/notification.rb', line 48

def self.mark_read_for(recipient, trigger)
  where(:recipient => recipient, :trigger => trigger)
    .update_all(:unread => false)
end

Instance Method Details

#descriptionObject



67
68
69
# File 'app/models/notify_on/notification.rb', line 67

def description
  description_cached || convert_string(description_raw)
end


63
64
65
# File 'app/models/notify_on/notification.rb', line 63

def link
  link_cached || convert_link(link_raw)
end

#read!Object

—————————————- Instance Methods



55
56
57
# File 'app/models/notify_on/notification.rb', line 55

def read!
  update_columns(:unread => false)
end

#read?Boolean

Returns:

  • (Boolean)


59
60
61
# File 'app/models/notify_on/notification.rb', line 59

def read?
  !unread?
end

#recipient_type=(sType) ⇒ Object



20
21
22
# File 'app/models/notify_on/notification.rb', line 20

def recipient_type=(sType)
  super(sType.to_s.classify.constantize.base_class.to_s)
end

#sender_type=(sType) ⇒ Object



24
25
26
# File 'app/models/notify_on/notification.rb', line 24

def sender_type=(sType)
  super(sType.to_s.classify.constantize.base_class.to_s)
end

#trigger_type=(sType) ⇒ Object



28
29
30
# File 'app/models/notify_on/notification.rb', line 28

def trigger_type=(sType)
  super(sType.to_s.classify.constantize.base_class.to_s)
end