module Rack::Attack::InstantiableFail2Ban

Make it instantiable like Throttle so we can introspect it

Constants

MANDATORY_OPTIONS

Attributes

bantime[R]
limit[R]
name[R]
period[R]
type[R]

Public Class Methods

new(name, options) click to toggle source
# File lib/rack/attack_extensions.rb, line 261
def initialize(name, options)
  @name = name
  MANDATORY_OPTIONS.each do |opt|
    raise ArgumentError.new("Must pass #{opt.inspect} option") unless options[opt]
  end
  @limit   = options[:limit]
  @period  = options[:period].respond_to?(:call) ? options[:period] : options[:period].to_i
  @bantime = options[:bantime]   or raise ArgumentError, "Must pass bantime option"
  @type    = options[:type]
end

Public Instance Methods

options() click to toggle source
# File lib/rack/attack_extensions.rb, line 275
def options
  {
    period: period,
    limit:  limit,
  }
end