Class: RateLimit::Result
- Inherits:
-
Object
- Object
- RateLimit::Result
- Defined in:
- lib/rate_limit/result.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
Attributes.
-
#threshold ⇒ Object
Attributes.
-
#topic ⇒ Object
Attributes.
-
#value ⇒ Object
Attributes.
Instance Method Summary collapse
- #failure!(worker) ⇒ Object
-
#initialize(topic:, value:) ⇒ Result
constructor
Methods.
- #success! ⇒ Object
- #success? ⇒ Boolean
Constructor Details
#initialize(topic:, value:) ⇒ Result
Methods
9 10 11 12 |
# File 'lib/rate_limit/result.rb', line 9 def initialize(topic:, value:) @topic = topic @value = value end |
Instance Attribute Details
#interval ⇒ Object
Attributes
6 7 8 |
# File 'lib/rate_limit/result.rb', line 6 def interval @interval end |
#threshold ⇒ Object
Attributes
6 7 8 |
# File 'lib/rate_limit/result.rb', line 6 def threshold @threshold end |
#topic ⇒ Object
Attributes
6 7 8 |
# File 'lib/rate_limit/result.rb', line 6 def topic @topic end |
#value ⇒ Object
Attributes
6 7 8 |
# File 'lib/rate_limit/result.rb', line 6 def value @value end |
Instance Method Details
#failure!(worker) ⇒ Object
22 23 24 25 26 |
# File 'lib/rate_limit/result.rb', line 22 def failure!(worker) @success = false @threshold = worker.exceeded_window&.threshold @interval = worker.exceeded_window&.interval end |
#success! ⇒ Object
18 19 20 |
# File 'lib/rate_limit/result.rb', line 18 def success! @success = true end |
#success? ⇒ Boolean
14 15 16 |
# File 'lib/rate_limit/result.rb', line 14 def success? @success end |