Class: Pecorino::Throttle::State
- Inherits:
-
Object
- Object
- Pecorino::Throttle::State
- Defined in:
- lib/pecorino/throttle.rb
Overview
The state represents a snapshot of the throttle state in time
Instance Attribute Summary collapse
- #blocked_until ⇒ Time readonly
Instance Method Summary collapse
-
#blocked? ⇒ Boolean
Tells whether this throttle still is in the blocked state.
-
#initialize(blocked_until) ⇒ State
constructor
A new instance of State.
Constructor Details
#initialize(blocked_until) ⇒ State
Returns a new instance of State.
14 15 16 |
# File 'lib/pecorino/throttle.rb', line 14 def initialize(blocked_until) @blocked_until = blocked_until end |
Instance Attribute Details
#blocked_until ⇒ Time (readonly)
12 13 14 |
# File 'lib/pecorino/throttle.rb', line 12 def blocked_until @blocked_until end |
Instance Method Details
#blocked? ⇒ Boolean
Tells whether this throttle still is in the blocked state. If the ‘blocked_until` value lies in the past, the method will return `false` - this is done so that the `State` can be cached.
23 24 25 |
# File 'lib/pecorino/throttle.rb', line 23 def blocked? !!(@blocked_until && @blocked_until > Time.now) end |