lib/bullet.rb in bullet-6.1.0 vs lib/bullet.rb in bullet-6.1.1
- old
+ new
@@ -36,11 +36,10 @@
:unused_eager_loading_enable,
:counter_cache_enable,
:stacktrace_includes,
:stacktrace_excludes,
:skip_html_injection
- attr_reader :whitelist
attr_accessor :add_footer, :orm_patches_applied
available_notifiers = UniformNotifier::AVAILABLE_NOTIFIERS.map { |notifier| "#{notifier}=" }
available_notifiers_options = { to: UniformNotifier }
delegate(*available_notifiers, **available_notifiers_options)
@@ -96,31 +95,31 @@
@stacktrace_excludes || []
end
def add_whitelist(options)
reset_whitelist
- @whitelist[options[:type]][options[:class_name]] ||= []
- @whitelist[options[:type]][options[:class_name]] << options[:association].to_sym
+ Thread.current[:whitelist][options[:type]][options[:class_name]] ||= []
+ Thread.current[: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? }
+ Thread.current[:whitelist][options[:type]][options[:class_name]] ||= []
+ Thread.current[:whitelist][options[:type]][options[:class_name]].delete(options[:association].to_sym)
+ Thread.current[:whitelist][options[:type]].delete_if { |_key, val| val.empty? }
end
def get_whitelist_associations(type, class_name)
- Array(@whitelist[type][class_name])
+ Array(Thread.current[:whitelist][type][class_name])
end
def reset_whitelist
- @whitelist ||= { n_plus_one_query: {}, unused_eager_loading: {}, counter_cache: {} }
+ Thread.current[:whitelist] ||= { n_plus_one_query: {}, unused_eager_loading: {}, counter_cache: {} }
end
def clear_whitelist
- @whitelist = nil
+ Thread.current[:whitelist] = nil
end
def bullet_logger=(active)
if active
require 'fileutils'
@@ -238,11 +237,11 @@
def console_enabled?
UniformNotifier.active_notifiers.include?(UniformNotifier::JavascriptConsole)
end
- def skip_html_injection?
- @skip_html_injection || false
+ def inject_into_page?
+ !@skip_html_injection && (console_enabled? || add_footer)
end
private
def for_each_active_notifier_with_notification