Class: RequestTracker::RateLimiters::Base

Inherits:
Object
  • Object
show all
Defined in:
lib/request_tracker/rate_limiters/base.rb

Direct Known Subclasses

IP, User

Instance Method Summary collapse

Constructor Details

#initialize(request, cookie) ⇒ Base

:nodoc:



7
8
9
10
# File 'lib/request_tracker/rate_limiters/base.rb', line 7

def initialize(request, cookie)
  @request = request
  @cookie = cookie
end

Instance Method Details

#active?Boolean

This method is meant to be implemented in subclasses.

Returns:

  • (Boolean)

    Indicates if the rate limiter should be used for the request.

Raises:

  • (NotImplementedError)


27
28
29
# File 'lib/request_tracker/rate_limiters/base.rb', line 27

def active?
  raise NotImplementedError
end

#error_code_identifierObject

:nodoc:



20
21
22
# File 'lib/request_tracker/rate_limiters/base.rb', line 20

def error_code_identifier
  self.class.name.underscore.split("/").last
end

#rate_limit_globally?Boolean

This method is meant to be implemented in subclasses.

Returns:

  • (Boolean)

    Indicates whether the rate limit applies globally across all sites in the cluster or just for the current site.

Raises:

  • (NotImplementedError)


35
36
37
# File 'lib/request_tracker/rate_limiters/base.rb', line 35

def rate_limit_globally?
  raise NotImplementedError
end

#rate_limit_keyString

This method is meant to be implemented in subclasses.

Returns:

  • (String)

    The key used to identify the rate limiter.

Raises:

  • (NotImplementedError)


15
16
17
# File 'lib/request_tracker/rate_limiters/base.rb', line 15

def rate_limit_key
  raise NotImplementedError
end