From 93421efa5a741fb4793d5c090a7a6563ba332adf Mon Sep 17 00:00:00 2001 From: Steve Hodgkiss Date: Wed, 2 Apr 2014 17:12:06 +1100 Subject: [PATCH] Tidy up defaults. We don't need to use ||= because this runs when the class gets loaded, and we won't have user supplied defaults yet. --- lib/rack/attack.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/rack/attack.rb b/lib/rack/attack.rb index 64c8b33..80a8801 100644 --- a/lib/rack/attack.rb +++ b/lib/rack/attack.rb @@ -76,9 +76,9 @@ class Rack::Attack end # Set defaults - @notifier ||= ActiveSupport::Notifications if defined?(ActiveSupport::Notifications) - @blacklisted_response ||= lambda {|env| [403, {}, ["Forbidden\n"]] } - @throttled_response ||= lambda {|env| + @notifier = ActiveSupport::Notifications if defined?(ActiveSupport::Notifications) + @blacklisted_response = lambda {|env| [403, {}, ["Forbidden\n"]] } + @throttled_response = lambda {|env| retry_after = env['rack.attack.match_data'][:period] rescue nil [429, {'Retry-After' => retry_after.to_s}, ["Retry later\n"]] }