Sha256: a7aafaaf43b4ed04bddbf9eb279576e9e4a68f9344ba2948ab3d718ccab804e4

Contents?: true

Size: 1.65 KB

Versions: 8

Compression:

Stored size: 1.65 KB

Contents

module Bullet
  class ActionController
    def self.enable
      require 'action_controller'
      case Rails.version
      when /^2.3/  
        ::ActionController::Dispatcher.middleware.use Bullet::Rack
        ::ActionController::Dispatcher.class_eval do
          class <<self
            alias_method :origin_reload_application, :reload_application
            def reload_application
              origin_reload_application
              Bullet.clear
            end
          end
        end
      when /^2.[2|1]/
        ::ActionController::Dispatcher.class_eval do
          alias_method :origin_reload_application, :reload_application
          def reload_application
            origin_reload_application
            Bullet.clear
          end
        end
        
        ::ActionController::Base.class_eval do
          alias_method :origin_process, :process
          def process(request, response, method = :perform_action, *arguments)
            Bullet.start_request
            response = origin_process(request, response, method = :perform_action, *arguments)
            
            if Bullet.notification?
              if response.headers["type"] and response.headers["type"].include? 'text/html' and response.body =~ %r{<html.*</html>}m
                response.body <<= Bullet.gather_inline_notifications
                response.headers["Content-Length"] = response.body.length.to_s
              end
            
              Bullet.perform_bullet_out_of_channel_notifications
            end
            Bullet.end_request
            response
          end
        end
      else
        puts "Gem Bullet: Unsupported rails version"
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
thaold-bullet-2.0.2 lib/bullet/action_controller2.rb
bullet-2.0.1 lib/bullet/action_controller2.rb
bullet-2.0.0 lib/bullet/action_controller2.rb
bullet-2.0.0.rc3 lib/bullet/action_controller2.rb
bullet-2.0.0.rc2 lib/bullet/action_controller2.rb
bullet-2.0.0.rc1 lib/bullet/action_controller2.rb
bullet-2.0.0.beta.4 lib/bullet/action_controller2.rb
bullet-2.0.0.beta.3 lib/bullet/action_controller2.rb