Sha256: 322697b73c9124633c871ba8b3667ec9ad3abf16fecaa60dc739b97dbd281c9c

Contents?: true

Size: 780 Bytes

Versions: 2

Compression:

Stored size: 780 Bytes

Contents

module Ahoy
  class Engine < ::Rails::Engine
    # from https://github.com/evrone/quiet_assets/blob/master/lib/quiet_assets.rb
    initializer "ahoy.middleware", after: "sprockets.environment" do
      next unless Ahoy.quiet

      # Parse PATH_INFO by assets prefix
      AHOY_PREFIX = "/ahoy/".freeze

      # Just create an alias for call in middleware
      Rails::Rack::Logger.class_eval do
        def call_with_quiet_ahoy(env)
          if env["PATH_INFO"].start_with?(AHOY_PREFIX) && logger.respond_to?(:silence_logger)
            logger.silence_logger do
              call_without_quiet_ahoy(env)
            end
          else
            call_without_quiet_ahoy(env)
          end
        end
        alias_method_chain :call, :quiet_ahoy
      end
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
ahoy_matey-1.2.1 lib/ahoy/engine.rb
ahoy_matey-1.2.0 lib/ahoy/engine.rb