Skip to content

Instantly share code, notes, and snippets.

@synth
Last active December 20, 2015 17:39
Show Gist options
  • Save synth/6170072 to your computer and use it in GitHub Desktop.
Save synth/6170072 to your computer and use it in GitHub Desktop.
ActionPusher customizations - Higher level customization of the ActionPusher gem https://github.com/agoragames/action_pusher
# NOTE: this architecture hinges on the channels being specific to the user
# this allows us to know what permissions context to render templates under
# seeing as how this may need to be run in a background task without a "current user" context
# so the "current user" is really the recipient of the notification
class ApplicationPusher < ActionPusher::Base
attr_accessor :channel, :event, :current_user
include ActionController::HideActions
include Authorization::AuthorizationInController
helper Authorization::AuthorizationHelper
helper_method :current_user
default_url_options[:host] = Recognize::Application.config.host
def initialize(channel, event, user)
@channel, @event, @current_user = channel, event, user
return self
end
def push!
Pushable.push(channel, event, self.push_object) if Rails.configuration.send_push_notifications
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment