Last active
December 20, 2015 17:39
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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