lib/bullet.rb in bullet-5.6.1 vs lib/bullet.rb in bullet-5.7.0
- old
+ new
@@ -36,16 +36,16 @@
available_notifiers = UniformNotifier::AVAILABLE_NOTIFIERS.map { |notifier| "#{notifier}=" }
available_notifiers << { :to => UniformNotifier }
delegate *available_notifiers
def raise=(should_raise)
- UniformNotifier.raise=(should_raise ? Notification::UnoptimizedQueryError : false)
+ UniformNotifier.raise = (should_raise ? Notification::UnoptimizedQueryError : false)
end
- DETECTORS = [ Bullet::Detector::NPlusOneQuery,
+ DETECTORS = [Bullet::Detector::NPlusOneQuery,
Bullet::Detector::UnusedEagerLoading,
- Bullet::Detector::CounterCache ].freeze
+ Bullet::Detector::CounterCache].freeze
def enable=(enable)
@enable = @n_plus_one_query_enable = @unused_eager_loading_enable = @counter_cache_enable = enable
if enable?
reset_whitelist
@@ -85,16 +85,23 @@
reset_whitelist
@whitelist[options[:type]][options[:class_name]] ||= []
@whitelist[options[:type]][options[:class_name]] << options[:association].to_sym
end
+ def delete_whitelist(options)
+ reset_whitelist
+ @whitelist[options[:type]][options[:class_name]] ||= []
+ @whitelist[options[:type]][options[:class_name]].delete(options[:association].to_sym)
+ @whitelist[options[:type]].delete_if { |key, val| val.empty? }
+ end
+
def get_whitelist_associations(type, class_name)
Array(@whitelist[type][class_name])
end
def reset_whitelist
- @whitelist ||= {:n_plus_one_query => {}, :unused_eager_loading => {}, :counter_cache => {}}
+ @whitelist ||= { :n_plus_one_query => {}, :unused_eager_loading => {}, :counter_cache => {} }
end
def clear_whitelist
@whitelist = nil
end
@@ -161,11 +168,11 @@
def gather_inline_notifications
responses = []
for_each_active_notifier_with_notification do |notification|
responses << notification.notify_inline
end
- responses.join( "\n" )
+ responses.join("\n")
end
def perform_out_of_channel_notifications(env = {})
request_uri = build_request_uri(env)
for_each_active_notifier_with_notification do |notification|
@@ -209,9 +216,10 @@
return_value
end
private
+
def for_each_active_notifier_with_notification
UniformNotifier.active_notifiers.each do |notifier|
notification_collector.collection.each do |notification|
notification.notifier = notifier
yield notification