class Notifly::NotificationChannel

Public Class Methods

new(user_id) click to toggle source
# File lib/services/notification_channel.rb, line 3
def initialize(user_id)
  @user_id = user_id
  @channel = WebsocketRails.users[@user_id.to_s]
  @action_view = Notifly::ActionViewHelper.new
end

Public Instance Methods

render(notification) click to toggle source
# File lib/services/notification_channel.rb, line 14
def render(notification)
  @action_view.render partial: 'layouts/notification',
    locals: { notification: notification }
end
trigger(notification) click to toggle source
# File lib/services/notification_channel.rb, line 9
def trigger(notification)
  @channel.send_message 'notifly.notifications.new',
    { message: render(notification), id: notification.id }
end