Class: RateLimit::Config
- Inherits:
-
Object
- Object
- RateLimit::Config
- Defined in:
- lib/rate_limit/config.rb,
lib/rate_limit/config/defaults.rb,
lib/rate_limit/config/file_loader.rb
Defined Under Namespace
Modules: Defaults, FileLoader
Instance Attribute Summary collapse
-
#default_interval ⇒ Object
Returns the value of attribute default_interval.
-
#default_threshold ⇒ Object
Returns the value of attribute default_threshold.
-
#fail_safe ⇒ Object
Returns the value of attribute fail_safe.
-
#limits_file_path ⇒ Object
Returns the value of attribute limits_file_path.
-
#on_failure ⇒ Object
Returns the value of attribute on_failure.
-
#on_success ⇒ Object
Returns the value of attribute on_success.
-
#redis ⇒ Object
Returns the value of attribute redis.
Instance Method Summary collapse
- #failure_callback(*args) ⇒ Object
-
#initialize ⇒ Config
constructor
A new instance of Config.
- #raw_limits_for(topic) ⇒ Object
- #success_callback(*args) ⇒ Object
Constructor Details
#initialize ⇒ Config
Returns a new instance of Config.
17 18 19 20 21 22 23 |
# File 'lib/rate_limit/config.rb', line 17 def initialize @redis = Redis.new @fail_safe = true @limits_file_path = Defaults::LIMITS_FILE_PATH @default_interval = Defaults::WINDOW_INTERVAL @default_threshold = Defaults::WINDOW_THRESHOLD end |
Instance Attribute Details
#default_interval ⇒ Object
Returns the value of attribute default_interval.
9 10 11 |
# File 'lib/rate_limit/config.rb', line 9 def default_interval @default_interval end |
#default_threshold ⇒ Object
Returns the value of attribute default_threshold.
9 10 11 |
# File 'lib/rate_limit/config.rb', line 9 def default_threshold @default_threshold end |
#fail_safe ⇒ Object
Returns the value of attribute fail_safe.
9 10 11 |
# File 'lib/rate_limit/config.rb', line 9 def fail_safe @fail_safe end |
#limits_file_path ⇒ Object
Returns the value of attribute limits_file_path.
9 10 11 |
# File 'lib/rate_limit/config.rb', line 9 def limits_file_path @limits_file_path end |
#on_failure ⇒ Object
Returns the value of attribute on_failure.
9 10 11 |
# File 'lib/rate_limit/config.rb', line 9 def on_failure @on_failure end |
#on_success ⇒ Object
Returns the value of attribute on_success.
9 10 11 |
# File 'lib/rate_limit/config.rb', line 9 def on_success @on_success end |
#redis ⇒ Object
Returns the value of attribute redis.
9 10 11 |
# File 'lib/rate_limit/config.rb', line 9 def redis @redis end |
Instance Method Details
#failure_callback(*args) ⇒ Object
33 34 35 |
# File 'lib/rate_limit/config.rb', line 33 def failure_callback(*args) on_failure&.call(*args) end |
#raw_limits_for(topic) ⇒ Object
25 26 27 |
# File 'lib/rate_limit/config.rb', line 25 def raw_limits_for(topic) raw_limits[topic] || Defaults.raw_limits end |
#success_callback(*args) ⇒ Object
29 30 31 |
# File 'lib/rate_limit/config.rb', line 29 def success_callback(*args) on_success&.call(*args) end |