Class: Alondra::PushController
- Inherits:
-
Object
- Object
- Alondra::PushController
- Includes:
- AbstractController::AssetPaths, AbstractController::Helpers, AbstractController::Logger, AbstractController::Rendering, AbstractController::Translation, ActiveSupport::Configurable
- Defined in:
- lib/alondra/push_controller.rb
Instance Attribute Summary collapse
-
#channel_names ⇒ Object
Returns the value of attribute channel_names.
-
#request ⇒ Object
Returns the value of attribute request.
Class Method Summary collapse
Instance Method Summary collapse
- #_prefixes ⇒ Object
- #action_name ⇒ Object
-
#initialize(context, to, request = nil) ⇒ PushController
constructor
A new instance of PushController.
- #protect_against_forgery? ⇒ Boolean
- #render_push(options) ⇒ Object
- #view_paths ⇒ Object
Constructor Details
#initialize(context, to, request = nil) ⇒ PushController
Returns a new instance of PushController.
15 16 17 18 19 20 21 |
# File 'lib/alondra/push_controller.rb', line 15 def initialize(context, to, request = nil) @channel_names = Channel.names_for(to) @request = request self.class.view_paths = ActionController::Base.view_paths copy_instance_variables_from(context) end |
Instance Attribute Details
#channel_names ⇒ Object
Returns the value of attribute channel_names.
12 13 14 |
# File 'lib/alondra/push_controller.rb', line 12 def channel_names @channel_names end |
#request ⇒ Object
Returns the value of attribute request.
13 14 15 |
# File 'lib/alondra/push_controller.rb', line 13 def request @request end |
Class Method Details
.protect_against_forgery? ⇒ Boolean
50 51 52 |
# File 'lib/alondra/push_controller.rb', line 50 def self.protect_against_forgery? false end |
Instance Method Details
#_prefixes ⇒ Object
34 35 36 |
# File 'lib/alondra/push_controller.rb', line 34 def _prefixes ['application'] end |
#action_name ⇒ Object
42 43 44 |
# File 'lib/alondra/push_controller.rb', line 42 def action_name 'push' end |
#protect_against_forgery? ⇒ Boolean
46 47 48 |
# File 'lib/alondra/push_controller.rb', line 46 def protect_against_forgery? false end |
#render_push(options) ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/alondra/push_controller.rb', line 23 def render_push() if EM.reactor_thread? Log.warn 'You are rendering a view from the Event Machine reactor thread' Log.warn 'Rendering a view is a possibly blocking operation, so be careful' end = render_to_string(*) msg = Message.new(, channel_names) msg.enqueue end |
#view_paths ⇒ Object
38 39 40 |
# File 'lib/alondra/push_controller.rb', line 38 def view_paths @view_paths ||= ApplicationController.send '_view_paths' end |