1class QuietLogger
 
2  attr_reader :app, :options, :paths
 
3
  • Complexity 1 » saikuro
4  def initialize(app, options = {})
 
5    @app = app
 
6    @options = options
 
7    @paths = Array(options[:paths])
 
8  end
 
 9
  • DuplicateMethodCall - calls 'app.call(env)' 2 times » reek
  • Complexity 3 » saikuro
10  def call(env)
 
11    if silence_request?(env)
 
12      logger.silence { app.call(env) }
 
13    else
 
14      app.call(env)
 
15    end
 
16  end
 
 
18  private
 
  • Complexity 2 » saikuro
20    def silence_request?(env)
 
21      paths.any? { |path| path === env['PATH_INFO'] }
 
22    end
 
  • UtilityFunction - doesn't depend on instance state (maybe move it to another class?) » reek
  • Complexity 1 » saikuro
24    def logger
 
25      Rails.logger
 
26    end
 
27end