Class: Alondra::PushController
- Inherits:
-
Object
- Object
- Alondra::PushController
- Includes:
- AbstractController::AssetPaths, AbstractController::Helpers, AbstractController::Logger, AbstractController::Rendering, AbstractController::Translation, ActionController::RequestForgeryProtection, 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.
Instance Method Summary collapse
- #_prefixes ⇒ Object
- #action_name ⇒ Object
-
#initialize(context, to, request = nil) ⇒ PushController
constructor
A new instance of PushController.
- #render_push(options) ⇒ Object
- #view_paths ⇒ Object
Constructor Details
#initialize(context, to, request = nil) ⇒ PushController
Returns a new instance of PushController.
14 15 16 17 18 19 20 |
# File 'lib/alondra/push_controller.rb', line 14 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.
11 12 13 |
# File 'lib/alondra/push_controller.rb', line 11 def channel_names @channel_names end |
#request ⇒ Object
Returns the value of attribute request.
12 13 14 |
# File 'lib/alondra/push_controller.rb', line 12 def request @request end |
Instance Method Details
#_prefixes ⇒ Object
33 34 35 |
# File 'lib/alondra/push_controller.rb', line 33 def _prefixes ['application'] end |
#action_name ⇒ Object
41 42 43 |
# File 'lib/alondra/push_controller.rb', line 41 def action_name 'push' end |
#render_push(options) ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/alondra/push_controller.rb', line 22 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
37 38 39 |
# File 'lib/alondra/push_controller.rb', line 37 def view_paths @view_paths ||= ApplicationController.send '_view_paths' end |