rack-attack/lib/rack/attack/check.rb
2012-07-28 19:51:24 -04:00

22 lines
440 B
Ruby

module Rack
module Attack
class Check
attr_reader :name, :block, :type
def initialize(name, block)
@name, @block = name, block
@type = nil
end
def [](req)
block[req].tap {|match|
if match
Rack::Attack.instrument(:type => type, :name => name, :request => req)
req.env["rack.attack.#{type}"] = name
end
}
end
end
end
end