lib/rack/throttle/matchers/matcher.rb in improved-rack-throttle-0.7.0 vs lib/rack/throttle/matchers/matcher.rb in improved-rack-throttle-0.7.1
- old
+ new
@@ -1,22 +1,30 @@
module Rack; module Throttle
###
- # This is the base class for matcher implementations
- # Implements IP, user agent, url, and request method based matching
- # e.g. implement throttling rules that discriminate by ip, user agent, url, request method,
- # or any combination thereof
+ # This is the base class for matcher implementations.
+ # Implementations are provided for User Agent, URL, and request
+ # method. Subclass Matcher if you want to provide a custom
+ # implementation.
class Matcher
attr_reader :rule
def initialize(rule)
@rule = rule
end
- # MUST return true or false
+ # Must be implemented in a subclass.
+ # MUST return true or false.
+ # @return [Boolean]
+ # @abstract
def match?
true
end
+ # Must be implemented in a subclass.
+ # Used to produce a unique key in our cache store.
+ # Typically of the form "xx-"
+ # @return [String]
+ # @abstract
def identifier
""
end
end