Class: Rack::Throttle::Matcher

Inherits:
Object
  • Object
show all
Defined in:
lib/rack/throttle/matchers/matcher.rb

Overview

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.

Direct Known Subclasses

MethodMatcher, UrlMatcher, UserAgentMatcher

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(rule) ⇒ Matcher

Returns a new instance of Matcher.



10
11
12
# File 'lib/rack/throttle/matchers/matcher.rb', line 10

def initialize(rule)
  @rule = rule
end

Instance Attribute Details

#ruleObject (readonly)

Returns the value of attribute rule.



8
9
10
# File 'lib/rack/throttle/matchers/matcher.rb', line 8

def rule
  @rule
end

Instance Method Details

#identifierString

This method is abstract.

Must be implemented in a subclass. Used to produce a unique key in our cache store. Typically of the form “xx-”

Returns:

  • (String)


27
28
29
# File 'lib/rack/throttle/matchers/matcher.rb', line 27

def identifier
  ""
end

#match?Boolean

This method is abstract.

Must be implemented in a subclass. MUST return true or false.

Returns:

  • (Boolean)


18
19
20
# File 'lib/rack/throttle/matchers/matcher.rb', line 18

def match?
  true
end