Class: Pecorino::Throttle::State

Inherits:
Object
  • Object
show all
Defined in:
lib/pecorino/throttle.rb

Overview

The state represents a snapshot of the throttle state in time

Instance Attribute Summary collapse

Instance Method Summary collapse

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_untilTime (readonly)

Returns:

  • (Time)


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.

Returns:

  • (Boolean)


23
24
25
# File 'lib/pecorino/throttle.rb', line 23

def blocked?
  !!(@blocked_until && @blocked_until > Time.now)
end