Skip to content

Commit 0188a90

Browse files
committed
refactor: DRY setting config defaults
1 parent 55cb6de commit 0188a90

1 file changed

Lines changed: 7 additions & 10 deletions

File tree

lib/rack/attack/configuration.rb

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -21,16 +21,7 @@ class Configuration
2121
attr_accessor :blocklisted_response, :throttled_response, :throttled_response_retry_after_header
2222

2323
def initialize
24-
@safelists = {}
25-
@blocklists = {}
26-
@throttles = {}
27-
@tracks = {}
28-
@anonymous_blocklists = []
29-
@anonymous_safelists = []
30-
@throttled_response_retry_after_header = false
31-
32-
@blocklisted_response = DEFAULT_BLOCKLISTED_RESPONSE
33-
@throttled_response = DEFAULT_THROTTLED_RESPONSE
24+
set_defaults
3425
end
3526

3627
def safelist(name = nil, &block)
@@ -92,6 +83,12 @@ def tracked?(request)
9283
end
9384

9485
def clear_configuration
86+
set_defaults
87+
end
88+
89+
private
90+
91+
def set_defaults
9592
@safelists = {}
9693
@blocklists = {}
9794
@throttles = {}

0 commit comments

Comments
 (0)