refactor: make Throttle.new consistent with Blocklist/Safelist.new

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

View file

@ -58,7 +58,7 @@ class Rack::Attack
end
def throttle(name, options, &block)
throttles[name] = Throttle.new(name, options, block)
throttles[name] = Throttle.new(name, options, &block)
end
def track(name, options = {}, &block)

View file

@ -6,7 +6,7 @@ module Rack
MANDATORY_OPTIONS = [:limit, :period].freeze
attr_reader :name, :limit, :period, :block, :type
def initialize(name, options, block)
def initialize(name, options, &block)
@name, @block = name, block
MANDATORY_OPTIONS.each do |opt|
raise ArgumentError, "Must pass #{opt.inspect} option" unless options[opt]

View file

@ -9,7 +9,7 @@ module Rack
options[:type] = :track
if options[:limit] && options[:period]
@filter = Throttle.new(name, options, block)
@filter = Throttle.new(name, options, &block)
else
@filter = Check.new(name, options, &block)
end