Class: Rack::Attack::Check
- Inherits:
-
Object
- Object
- Rack::Attack::Check
- Defined in:
- lib/rack/attack/check.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
readonly
Returns the value of attribute block.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(name, options = {}, &block) ⇒ Check
constructor
A new instance of Check.
- #matched_by?(request) ⇒ Boolean
Constructor Details
#initialize(name, options = {}, &block) ⇒ Check
Returns a new instance of Check.
8 9 10 11 12 |
# File 'lib/rack/attack/check.rb', line 8 def initialize(name, = {}, &block) @name = name @block = block @type = .fetch(:type, nil) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
6 7 8 |
# File 'lib/rack/attack/check.rb', line 6 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
6 7 8 |
# File 'lib/rack/attack/check.rb', line 6 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
6 7 8 |
# File 'lib/rack/attack/check.rb', line 6 def type @type end |
Instance Method Details
#matched_by?(request) ⇒ Boolean
14 15 16 17 18 19 20 21 22 |
# File 'lib/rack/attack/check.rb', line 14 def matched_by?(request) block.call(request).tap do |match| if match request.env["rack.attack.matched"] = name request.env["rack.attack.match_type"] = type Rack::Attack.instrument(request) end end end |