refactor: avoid unnecessary nil argument passing

This commit is contained in:
Gonzalo Rodriguez 2019-03-01 22:22:11 -03:00
parent 0e8dff4c88
commit fcb89a6c12
No known key found for this signature in database
GPG key ID: 5DB8B81B049B8AB1
3 changed files with 4 additions and 4 deletions

View file

@ -50,11 +50,11 @@ class Rack::Attack
end end
def blocklist_ip(ip_address) def blocklist_ip(ip_address)
anonymous_blocklists << Blocklist.new(nil) { |request| IPAddr.new(ip_address).include?(IPAddr.new(request.ip)) } anonymous_blocklists << Blocklist.new { |request| IPAddr.new(ip_address).include?(IPAddr.new(request.ip)) }
end end
def safelist_ip(ip_address) def safelist_ip(ip_address)
anonymous_safelists << Safelist.new(nil) { |request| IPAddr.new(ip_address).include?(IPAddr.new(request.ip)) } anonymous_safelists << Safelist.new { |request| IPAddr.new(ip_address).include?(IPAddr.new(request.ip)) }
end end
def throttle(name, options, &block) def throttle(name, options, &block)

View file

@ -3,7 +3,7 @@
module Rack module Rack
class Attack class Attack
class Blocklist < Check class Blocklist < Check
def initialize(name, &block) def initialize(name = nil, &block)
super super
@type = :blocklist @type = :blocklist
end end

View file

@ -3,7 +3,7 @@
module Rack module Rack
class Attack class Attack
class Safelist < Check class Safelist < Check
def initialize(name, &block) def initialize(name = nil, &block)
super super
@type = :safelist @type = :safelist
end end