Class: Rack::Congestion::PathLimiter

Inherits:
Limiter
  • Object
show all
Defined in:
lib/rack/congestion/path_limiter.rb

Instance Attribute Summary collapse

Attributes inherited from Limiter

#app, #env, #options

Instance Method Summary collapse

Methods inherited from Limiter

#backoff, #call, #rejected_response, #request

Constructor Details

#initialize(app, options = { }) ⇒ PathLimiter

Returns a new instance of PathLimiter.



6
7
8
9
10
# File 'lib/rack/congestion/path_limiter.rb', line 6

def initialize(app, options = { })
  self.path = normalize_path_from options
  self.path_matcher = normalize_matcher_from options
  super
end

Instance Attribute Details

#pathObject

Returns the value of attribute path.



4
5
6
# File 'lib/rack/congestion/path_limiter.rb', line 4

def path
  @path
end

#path_matcherObject

Returns the value of attribute path_matcher.



4
5
6
# File 'lib/rack/congestion/path_limiter.rb', line 4

def path_matcher
  @path_matcher
end

Instance Method Details

#_call(env) ⇒ Object



12
13
14
15
# File 'lib/rack/congestion/path_limiter.rb', line 12

def _call(env)
  @env = env
  ignored? ? app.call(env) : super(env)
end

#ignored?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/rack/congestion/path_limiter.rb', line 21

def ignored?
  request.path !~ path_matcher
end

#keyObject



17
18
19
# File 'lib/rack/congestion/path_limiter.rb', line 17

def key
  ->{ path }
end