Class: UNotifier::Provider::User::ActionCable
- Inherits:
-
ProviderBase
- Object
- ProviderBase
- UNotifier::Provider::User::ActionCable
- Defined in:
- lib/provider/user/action_cable.rb
Instance Attribute Summary collapse
-
#autohide_delay ⇒ Object
Returns the value of attribute autohide_delay.
-
#channel_name ⇒ Object
Returns the value of attribute channel_name.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
-
#initialize(server, channel_name: nil, autohide_delay: 30, notification_conditions: []) ⇒ ActionCable
constructor
A new instance of ActionCable.
- #notify(notification) ⇒ Object
- #sensitive? ⇒ Boolean
- #serialize_notification(notification) ⇒ Object
Methods inherited from ProviderBase
Constructor Details
#initialize(server, channel_name: nil, autohide_delay: 30, notification_conditions: []) ⇒ ActionCable
Returns a new instance of ActionCable.
8 9 10 11 12 13 |
# File 'lib/provider/user/action_cable.rb', line 8 def initialize(server, channel_name: nil, autohide_delay: 30, notification_conditions: []) super(notification_conditions: notification_conditions) @server = server @channel_name = channel_name @autohide_delay = autohide_delay end |
Instance Attribute Details
#autohide_delay ⇒ Object
Returns the value of attribute autohide_delay.
6 7 8 |
# File 'lib/provider/user/action_cable.rb', line 6 def autohide_delay @autohide_delay end |
#channel_name ⇒ Object
Returns the value of attribute channel_name.
6 7 8 |
# File 'lib/provider/user/action_cable.rb', line 6 def channel_name @channel_name end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
5 6 7 |
# File 'lib/provider/user/action_cable.rb', line 5 def server @server end |
Instance Method Details
#notify(notification) ⇒ Object
15 16 17 18 19 |
# File 'lib/provider/user/action_cable.rb', line 15 def notify(notification) return unless can_notify?(notification) server.broadcast channel_name.call(notification), serialize_notification(notification) end |
#sensitive? ⇒ Boolean
21 22 23 |
# File 'lib/provider/user/action_cable.rb', line 21 def sensitive? false end |
#serialize_notification(notification) ⇒ Object
25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/provider/user/action_cable.rb', line 25 def serialize_notification(notification) { id: notification.id, title: notification.title, body: notification.body, autohide_delay: notification.autohide_delay || @autohide_delay, user_login: notification.target.login, link: notification.link, urgency: notification.urgency, } end |