lib/alondra/push_controller.rb in alondra-0.0.3 vs lib/alondra/push_controller.rb in alondra-0.0.4

- old
+ new

@@ -4,26 +4,27 @@ include AbstractController::Logger include AbstractController::Rendering include AbstractController::Helpers include AbstractController::Translation include AbstractController::AssetPaths - include AbstractController::ViewPaths + include ActionController::RequestForgeryProtection attr_accessor :channel_names + attr_accessor :request - def initialize(context, to) + 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 def render_push(options) - if EM.reactor_thread? - Rails.logger.warn('Your are rendering a view from the Event Machine reactor thread') - Rails.logger.warn('Rendering a view is a possibly blocking operation, so be careful') + 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 message_content = render_to_string(*options) msg = Message.new(message_content, channel_names) msg.enqueue @@ -34,10 +35,10 @@ end def view_paths @view_paths ||= ApplicationController.send '_view_paths' end - + def action_name 'push' end private \ No newline at end of file