mirror of
https://github.com/samsonjs/rack-attack.git
synced 2026-03-26 09:35:49 +00:00
* attempt to improve semantics for legibility * Attempt to improve legibility by simplifying * Make it more clear that we're calling procs/blocks here * Enable rubocop Style/BlockDelimiters cop * Prefer 'request' over 'req' abbreviation for legibility/clarity * Instances of Track named 'track' not 'tracker'
21 lines
436 B
Ruby
21 lines
436 B
Ruby
module Rack
|
|
class Attack
|
|
class Track
|
|
attr_reader :filter
|
|
|
|
def initialize(name, options = {}, block)
|
|
options[:type] = :track
|
|
|
|
if options[:limit] && options[:period]
|
|
@filter = Throttle.new(name, options, block)
|
|
else
|
|
@filter = Check.new(name, options, block)
|
|
end
|
|
end
|
|
|
|
def matched_by?(request)
|
|
filter.matched_by?(request)
|
|
end
|
|
end
|
|
end
|
|
end
|