Module: Rack::Attack::InstantiableFail2Ban
- Includes:
- InspectWithOptions, PeriodIntrospection
- Included in:
- Fail2Ban
- Defined in:
- lib/rack/attack_extensions.rb
Overview
Make it instantiable like Throttle so we can introspect it
Constant Summary collapse
- MANDATORY_OPTIONS =
[:limit, :period, :type].freeze
Instance Attribute Summary collapse
-
#bantime ⇒ Object
readonly
Returns the value of attribute bantime.
-
#limit ⇒ Object
readonly
Returns the value of attribute limit.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#period ⇒ Object
readonly
Returns the value of attribute period.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
Methods included from InspectWithOptions
Methods included from PeriodIntrospection
Instance Attribute Details
#bantime ⇒ Object (readonly)
Returns the value of attribute bantime.
260 261 262 |
# File 'lib/rack/attack_extensions.rb', line 260 def bantime @bantime end |
#limit ⇒ Object (readonly)
Returns the value of attribute limit.
260 261 262 |
# File 'lib/rack/attack_extensions.rb', line 260 def limit @limit end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
260 261 262 |
# File 'lib/rack/attack_extensions.rb', line 260 def name @name end |
#period ⇒ Object (readonly)
Returns the value of attribute period.
260 261 262 |
# File 'lib/rack/attack_extensions.rb', line 260 def period @period end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
260 261 262 |
# File 'lib/rack/attack_extensions.rb', line 260 def type @type end |
Instance Method Details
#initialize(name, options) ⇒ Object
261 262 263 264 265 266 267 268 269 270 |
# File 'lib/rack/attack_extensions.rb', line 261 def initialize(name, ) @name = name MANDATORY_OPTIONS.each do |opt| raise ArgumentError.new("Must pass #{opt.inspect} option") unless [opt] end @limit = [:limit] @period = [:period].respond_to?(:call) ? [:period] : [:period].to_i @bantime = [:bantime] or raise ArgumentError, "Must pass bantime option" @type = [:type] end |
#options ⇒ Object
275 276 277 278 279 280 |
# File 'lib/rack/attack_extensions.rb', line 275 def { period: period, limit: limit, } end |