refactor: DRY setting config defaults

This commit is contained in:
Gonzalo Rodriguez 2019-10-17 14:27:32 -03:00
parent 55cb6def03
commit 0188a90ab2
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1

View file

@ -21,16 +21,7 @@ module Rack
attr_accessor :blocklisted_response, :throttled_response, :throttled_response_retry_after_header
def initialize
@safelists = {}
@blocklists = {}
@throttles = {}
@tracks = {}
@anonymous_blocklists = []
@anonymous_safelists = []
@throttled_response_retry_after_header = false
@blocklisted_response = DEFAULT_BLOCKLISTED_RESPONSE
@throttled_response = DEFAULT_THROTTLED_RESPONSE
set_defaults
end
def safelist(name = nil, &block)
@ -92,6 +83,12 @@ module Rack
end
def clear_configuration
set_defaults
end
private
def set_defaults
@safelists = {}
@blocklists = {}
@throttles = {}