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
- #[](req) ⇒ Object
-
#initialize(name, options = {}, block) ⇒ Check
constructor
A new instance of Check.
Constructor Details
#initialize(name, options = {}, block) ⇒ Check
Returns a new instance of Check.
5 6 7 8 |
# File 'lib/rack/attack/check.rb', line 5 def initialize(name, = {}, block) @name, @block = name, block @type = .fetch(:type, nil) end |
Instance Attribute Details
#block ⇒ Object (readonly)
Returns the value of attribute block.
4 5 6 |
# File 'lib/rack/attack/check.rb', line 4 def block @block end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
4 5 6 |
# File 'lib/rack/attack/check.rb', line 4 def name @name end |
#type ⇒ Object (readonly)
Returns the value of attribute type.
4 5 6 |
# File 'lib/rack/attack/check.rb', line 4 def type @type end |
Instance Method Details
#[](req) ⇒ Object
10 11 12 13 14 15 16 17 18 |
# File 'lib/rack/attack/check.rb', line 10 def [](req) block[req].tap {|match| if match req.env["rack.attack.matched"] = name req.env["rack.attack.match_type"] = type Rack::Attack.instrument(req) end } end |