Avoid user confusion by renaming .clear! to .clear_configuration

This commit is contained in:
Gonzalo Rodriguez 2018-05-18 18:23:59 -03:00
parent cf672d60c1
commit a99722bf4b
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1
2 changed files with 7 additions and 2 deletions

View file

@ -120,12 +120,17 @@ class Rack::Attack
@cache ||= Cache.new @cache ||= Cache.new
end end
def clear! def clear_configuration
@safelists, @blocklists, @throttles, @tracks = {}, {}, {}, {} @safelists, @blocklists, @throttles, @tracks = {}, {}, {}, {}
@ip_blocklists = [] @ip_blocklists = []
@ip_safelists = [] @ip_safelists = []
end end
def clear!
warn "[DEPRECATION] Rack::Attack.clear! is deprecated. Please use Rack::Attack.clear_configuration instead"
clear_configuration
end
def blacklisted_response=(res) def blacklisted_response=(res)
warn "[DEPRECATION] 'Rack::Attack.blacklisted_response=' is deprecated. Please use 'blocklisted_response=' instead." warn "[DEPRECATION] 'Rack::Attack.blacklisted_response=' is deprecated. Please use 'blocklisted_response=' instead."
self.blocklisted_response = res self.blocklisted_response = res

View file

@ -28,7 +28,7 @@ class MiniTest::Spec
end end
after do after do
Rack::Attack.clear! Rack::Attack.clear_configuration
Rack::Attack.instance_variable_set(:@cache, nil) Rack::Attack.instance_variable_set(:@cache, nil)
Rack::Attack.throttled_response = @_original_throttled_response Rack::Attack.throttled_response = @_original_throttled_response