lib/bullet.rb in bullet-5.7.0 vs lib/bullet.rb in bullet-5.7.1

- old
+ new

@@ -27,17 +27,17 @@ end end end class << self - attr_writer :enable, :n_plus_one_query_enable, :unused_eager_loading_enable, :counter_cache_enable, :stacktrace_includes, :stacktrace_excludes - attr_reader :notification_collector, :whitelist + attr_writer :n_plus_one_query_enable, :unused_eager_loading_enable, :counter_cache_enable, :stacktrace_includes, :stacktrace_excludes + attr_reader :whitelist attr_accessor :add_footer, :orm_pathches_applied available_notifiers = UniformNotifier::AVAILABLE_NOTIFIERS.map { |notifier| "#{notifier}=" } - available_notifiers << { :to => UniformNotifier } - delegate *available_notifiers + available_notifiers << { to: UniformNotifier } + delegate(*available_notifiers) def raise=(should_raise) UniformNotifier.raise = (should_raise ? Notification::UnoptimizedQueryError : false) end @@ -60,19 +60,19 @@ def enable? !!@enable end def n_plus_one_query_enable? - self.enable? && !!@n_plus_one_query_enable + enable? && !!@n_plus_one_query_enable end def unused_eager_loading_enable? - self.enable? && !!@unused_eager_loading_enable + enable? && !!@unused_eager_loading_enable end def counter_cache_enable? - self.enable? && !!@counter_cache_enable + enable? && !!@counter_cache_enable end def stacktrace_includes @stacktrace_includes || [] end @@ -89,29 +89,29 @@ 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? } + @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 def bullet_logger=(active) if active require 'fileutils' - root_path = "#{rails? ? Rails.root.to_s : Dir.pwd}" + root_path = (rails? ? Rails.root.to_s : Dir.pwd).to_s FileUtils.mkdir_p(root_path + '/log') bullet_log_file = File.open("#{root_path}/log/bullet.log", 'a+') bullet_log_file.sync = true UniformNotifier.customized_logger = bullet_log_file end @@ -217,25 +217,25 @@ 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 - end + def for_each_active_notifier_with_notification + UniformNotifier.active_notifiers.each do |notifier| + notification_collector.collection.each do |notification| + notification.notifier = notifier + yield notification end end + end - def build_request_uri(env) - return "#{env['REQUEST_METHOD']} #{env['REQUEST_URI']}" if env['REQUEST_URI'] + def build_request_uri(env) + return "#{env['REQUEST_METHOD']} #{env['REQUEST_URI']}" if env['REQUEST_URI'] - if env['QUERY_STRING'].present? - "#{env['REQUEST_METHOD']} #{env['PATH_INFO']}?#{env['QUERY_STRING']}" - else - "#{env['REQUEST_METHOD']} #{env['PATH_INFO']}" - end + if env['QUERY_STRING'].present? + "#{env['REQUEST_METHOD']} #{env['PATH_INFO']}?#{env['QUERY_STRING']}" + else + "#{env['REQUEST_METHOD']} #{env['PATH_INFO']}" end + end end end