lib/bullet.rb in bullet-2.2.1 vs lib/bullet.rb in bullet-2.3.0
- old
+ new
@@ -1,12 +1,18 @@
require 'set'
require 'uniform_notifier'
+class Object
+ def ar_key
+ "#{self.class}:#{self.id}"
+ end
+end
+
module Bullet
- if Rails.version =~ /^3\.0/
+ if Rails.version =~ /\A3\.0/
autoload :ActiveRecord, 'bullet/active_record3'
- elsif Rails.version =~ /^3\.[12]/
+ elsif Rails.version =~ /\A3\.[12]/
autoload :ActiveRecord, 'bullet/active_record31'
else
autoload :ActiveRecord, 'bullet/active_record2'
autoload :ActionController, 'bullet/action_controller2'
end
@@ -37,11 +43,11 @@
def enable=(enable)
@enable = enable
if enable?
Bullet::ActiveRecord.enable
- if Rails.version =~ /^2./
+ if Rails.version =~ /\A2./
Bullet::ActionController.enable
end
end
end
@@ -49,27 +55,27 @@
@enable == true
end
def bullet_logger=(active)
if active
- bullet_log_file = File.open( 'log/bullet.log', 'a+' )
+ bullet_log_file = File.open('log/bullet.log', 'a+')
bullet_log_file.sync
UniformNotifier.customized_logger = bullet_log_file
end
end
def start_request
notification_collector.reset
- DETECTORS.each {|bullet| bullet.start_request}
+ DETECTORS.each { |bullet| bullet.start_request }
end
def end_request
- DETECTORS.each {|bullet| bullet.end_request}
+ DETECTORS.each { |bullet| bullet.end_request }
end
def clear
- DETECTORS.each {|bullet| bullet.clear}
+ DETECTORS.each { |bullet| bullet.clear }
end
def notification_collector
@notification_collector ||= Bullet::NotificationCollector.new
end
@@ -102,7 +108,6 @@
yield notification
end
end
end
end
-
end