Better cache interface

This commit is contained in:
Aaron Suggs 2012-08-06 14:16:08 -04:00
parent e135f17386
commit 6784f21612
2 changed files with 6 additions and 3 deletions

View file

@ -7,7 +7,7 @@ module Rack::Attack
class << self
attr_accessor :cache, :notifier, :blacklisted_response, :throttled_response
attr_accessor :notifier, :blacklisted_response, :throttled_response
def whitelist(name, &block)
self.whitelists[name] = Whitelist.new(name, block)
@ -29,7 +29,6 @@ module Rack::Attack
@app = app
# Set defaults
@cache ||= Cache.new
@notifier ||= ActiveSupport::Notifications if defined?(ActiveSupport::Notifications)
@blacklisted_response ||= lambda {|env| [503, {}, ['Blocked']] }
@throttled_response ||= lambda {|env|
@ -78,6 +77,10 @@ module Rack::Attack
notifier.instrument('rack.attack', req) if notifier
end
def cache
@cache ||= Cache.new
end
def clear!
@whitelists, @blacklists, @throttles = {}, {}, {}
end

View file

@ -1,5 +1,5 @@
module Rack
module Attack
VERSION = '1.1.0'
VERSION = '1.2.0'
end
end