Class: HTTPigeon::CircuitBreaker::DataBucket

Inherits:
Object
  • Object
show all
Defined in:
lib/httpigeon/circuit_breaker/memory_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, expires_at) ⇒ DataBucket

Returns a new instance of DataBucket.



91
92
93
94
# File 'lib/httpigeon/circuit_breaker/memory_store.rb', line 91

def initialize(value, expires_at)
  @value = value
  @expires_at = expires_at
end

Instance Attribute Details

#expires_atObject

Returns the value of attribute expires_at.



89
90
91
# File 'lib/httpigeon/circuit_breaker/memory_store.rb', line 89

def expires_at
  @expires_at
end

#valueObject

Returns the value of attribute value.



89
90
91
# File 'lib/httpigeon/circuit_breaker/memory_store.rb', line 89

def value
  @value
end

Instance Method Details

#expired?(current_time = Time.now.to_i) ⇒ Boolean

Returns:

  • (Boolean)


96
97
98
# File 'lib/httpigeon/circuit_breaker/memory_store.rb', line 96

def expired?(current_time = Time.now.to_i)
  expires_at < current_time
end

#to_hObject



100
101
102
# File 'lib/httpigeon/circuit_breaker/memory_store.rb', line 100

def to_h
  { value: value, expires_at: expires_at }
end