Class: Rack::PooledThrottle::Throttle

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/pooledthrottle/throttle.rb

Direct Known Subclasses

MemcachedThrottle

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

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

Returns a new instance of Throttle.



6
7
8
# File 'lib/rack/pooledthrottle/throttle.rb', line 6

def initialize(app, options = {})
  @app, @options = app, options
end

Instance Attribute Details

#appObject (readonly)

Returns the value of attribute app.



4
5
6
# File 'lib/rack/pooledthrottle/throttle.rb', line 4

def app
  @app
end

#optionsObject (readonly)

Returns the value of attribute options.



4
5
6
# File 'lib/rack/pooledthrottle/throttle.rb', line 4

def options
  @options
end

Instance Method Details

#call(env) ⇒ Object



10
11
12
13
# File 'lib/rack/pooledthrottle/throttle.rb', line 10

def call(env)
  request = Rack::Request.new(env)
  allowed?(request) ? app.call(env) : rate_limit_exceeded(request)
end