lib/bullet.rb in bullet-1.7.6 vs lib/bullet.rb in bullet-2.0.0.beta.1
- old
+ new
@@ -1,11 +1,14 @@
-require 'action_controller/dispatcher'
require 'bulletware'
module Bullet
- autoload :ActiveRecord, 'bullet/active_record'
- autoload :ActionController, 'bullet/action_controller'
+ if Rails.version =~ /^3.0/
+ autoload :ActiveRecord, 'bullet/active_record3'
+ else
+ autoload :ActiveRecord, 'bullet/active_record2'
+ autoload :ActionController, 'bullet/action_controller2'
+ end
autoload :Association, 'bullet/association'
autoload :Counter, 'bullet/counter'
autoload :BulletLogger, 'bullet/logger'
autoload :Notification, 'bullet/notification'
@@ -14,11 +17,15 @@
def enable=(enable)
@enable = enable
if enable?
Bullet::ActiveRecord.enable
- Bullet::ActionController.enable
- if ::Rails::VERSION::STRING =~ /^2.3/
+ if Rails.version =~ /^3.0/
+ require 'action_controller/metal'
+ ::ActionController::Metal.middleware_stack.use Bulletware
+ elsif Rails.version =~/^2.3/
+ Bullet::ActionController.enable
+ require 'action_controller/dispatcher'
::ActionController::Dispatcher.middleware.use Bulletware
end
end
end