-
Notifications
You must be signed in to change notification settings - Fork 1
The Notification Object
Sean C Davis edited this page Sep 5, 2016
·
1 revision
The NotifyOn::Notification
class is tucked away in the gem so you don't have to worry about it. But it'd be nice to know what you can do with it, right?
Associations on a notification object are generally eager loaded. They are:
-
recipient
is the object that received the notification (to
) -
sender
is the object that sent the notification (from
) -
trigger
is the object that triggered the notification (the model where you callednotify_on
)
There are a few attributes that a notification resolves for you:
-
description
: the interpolated description (message
). See String Interpolation. -
link
: the resolved reference link (link
). See Dynamic Link Generator. -
unread
: whether or not the notification has been read. It is set tofalse
by default when you a notification is created. -
options
: aHash
of the options you passed tonotify_on
. (Hint: Usingopts
instead ofoptions
returns aHashie::Mash
object, which can be easier to work with.)
Email settings are resolved via the combination of NotifyOn's default settings, your settings from config/intitializers/notify_on.rb
and the notification's individual options.
-
email_template
: name of the email template to use -
email_from
: email address that sent the notification -
email_subject
: subject of the email message
Pushere settings are resolved via the combination of NotifyOn's default settings, your settings from config/intitializers/notify_on.rb
and the notification's individual options.
-
pusher_sender_active?
: if the notification sender is present in the Pusher channel the notification was sent to. -
pusher_recipient_active?
: if the notification recipient is present in the Pusher channel the notification was sent to. -
pusher_channel_name
: name of the channel to send the Pusher notification -
pusher_event_name
: name of the notification's Pusher event -
pusher_attrs
: a Hash including thetrigger
andnotification
, along with any custom options you set
You can alter the notification with the following:
-
read!
will setunread
tofalse
. -
push!
will send the push notification via Pusher, but all the appropriate options must be in place. -
send_email
will send the email message if the appropriate options are in place.