diff --git a/lib/rack/attack.rb b/lib/rack/attack.rb index 3c90002..4511e99 100644 --- a/lib/rack/attack.rb +++ b/lib/rack/attack.rb @@ -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 diff --git a/lib/rack/attack/version.rb b/lib/rack/attack/version.rb index 6d2484b..0709ab6 100644 --- a/lib/rack/attack/version.rb +++ b/lib/rack/attack/version.rb @@ -1,5 +1,5 @@ module Rack module Attack - VERSION = '1.1.0' + VERSION = '1.2.0' end end