Class: Rack::Insight::PathFilter

Inherits:
Object
  • Object
show all
Includes:
Logging
Defined in:
lib/rack/insight/path-filter.rb

Instance Method Summary collapse

Methods included from Logging

logger, verbose, verbosity

Constructor Details

#initialize(app) ⇒ PathFilter

Returns a new instance of PathFilter.



6
7
8
# File 'lib/rack/insight/path-filter.rb', line 6

def initialize(app)
  @app = app
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/rack/insight/path-filter.rb', line 10

def call(env)
  filters = env['rack-insight.path_filters'].map do |string|
    %r{^#{string}}
  end

  unless filter = filters.find{|regex| regex =~ env['PATH_INFO']}
    return [404, {}, []]
  end

  logger.debug{ "Shortcutting collection stack: #{filter} =~ #{env['PATH_INFO']}"} if verbose(:debug)
  return @app.call(env)
end