Class: Sprockets::Rails::QuietAssets

Inherits:
Object
  • Object
show all
Defined in:
lib/sprockets/rails/quiet_assets.rb

Instance Method Summary collapse

Constructor Details

#initialize(app) ⇒ QuietAssets

Returns a new instance of QuietAssets.



6
7
8
9
# File 'lib/sprockets/rails/quiet_assets.rb', line 6

def initialize(app)
  @app = app
  @assets_regex = %r(\A/{0,2}#{::Rails.application.config.assets.prefix})
end

Instance Method Details

#call(env) ⇒ Object



11
12
13
14
15
16
17
18
19
# File 'lib/sprockets/rails/quiet_assets.rb', line 11

def call(env)
  if env['PATH_INFO'] =~ @assets_regex
    raise_logger_silence_error unless ::Rails.logger.respond_to?(:silence)

    ::Rails.logger.silence { @app.call(env) }
  else
    @app.call(env)
  end
end