Class: Galago::RateLimiter::Configuration
- Inherits:
-
Object
- Object
- Galago::RateLimiter::Configuration
- Includes:
- Singleton
- Defined in:
- lib/galago/rate_limiter/configuration.rb
Constant Summary collapse
- DEFAULT_LIMIT =
5_000- DEFAULT_API_KEY_HEADER =
'HTTP_X_API_KEY'.freeze
- DEFAULT_CALLBACK =
Proc.new {}
Instance Attribute Summary collapse
-
#api_key_header ⇒ Object
Returns the value of attribute api_key_header.
-
#counter ⇒ Object
Returns the value of attribute counter.
-
#limit ⇒ Object
Returns the value of attribute limit.
Instance Method Summary collapse
- #callback(&block) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #reset! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
14 15 16 17 18 |
# File 'lib/galago/rate_limiter/configuration.rb', line 14 def initialize @limit = DEFAULT_LIMIT @api_key_header = DEFAULT_API_KEY_HEADER @callback = DEFAULT_CALLBACK end |
Instance Attribute Details
#api_key_header ⇒ Object
Returns the value of attribute api_key_header.
12 13 14 |
# File 'lib/galago/rate_limiter/configuration.rb', line 12 def api_key_header @api_key_header end |
#counter ⇒ Object
Returns the value of attribute counter.
12 13 14 |
# File 'lib/galago/rate_limiter/configuration.rb', line 12 def counter @counter end |
#limit ⇒ Object
Returns the value of attribute limit.
12 13 14 |
# File 'lib/galago/rate_limiter/configuration.rb', line 12 def limit @limit end |
Instance Method Details
#callback(&block) ⇒ Object
41 42 43 44 45 46 47 |
# File 'lib/galago/rate_limiter/configuration.rb', line 41 def callback(&block) if block_given? @callback = block else @callback end end |
#reset! ⇒ Object
49 50 51 52 |
# File 'lib/galago/rate_limiter/configuration.rb', line 49 def reset! @limit = DEFAULT_LIMIT @api_key_header = DEFAULT_API_KEY_HEADER end |