mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-25 09:25:49 +00:00
extract mandatory options constant
This commit is contained in:
parent
7002a2a5cd
commit
7f3a24022b
1 changed files with 2 additions and 1 deletions
|
|
@ -1,10 +1,11 @@
|
|||
module Rack
|
||||
module Attack
|
||||
class Throttle
|
||||
MANDATORY_OPTIONS = [:limit, :period]
|
||||
attr_reader :name, :limit, :period, :block
|
||||
def initialize(name, options, block)
|
||||
@name, @block = name, block
|
||||
[:limit, :period].each do |opt|
|
||||
MANDATORY_OPTIONS.each do |opt|
|
||||
raise ArgumentError.new("Must pass #{opt.inspect} option") unless options[opt]
|
||||
end
|
||||
@limit = options[:limit]
|
||||
|
|
|
|||
Loading…
Reference in a new issue