mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
refactor: make Throttle.new consistent with Blocklist/Safelist.new
This commit is contained in:
parent
3639afc196
commit
0e8dff4c88
3 changed files with 3 additions and 3 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Reference in a new issue