Class: TimeoutCache::TimedObject

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

Overview

Wraps an object by attaching a time to it.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(value, time) ⇒ TimedObject

Returns a new instance of TimedObject.



22
23
24
25
# File 'lib/timeout_cache.rb', line 22

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

Instance Attribute Details

#expires_atObject (readonly)

:nodoc:



20
21
22
# File 'lib/timeout_cache.rb', line 20

def expires_at
  @expires_at
end

#valueObject (readonly)

:nodoc:



20
21
22
# File 'lib/timeout_cache.rb', line 20

def value
  @value
end

Instance Method Details

#expired?Boolean

Returns true if the object has expired. Returns false if the object has not yet expired.

Returns:

  • (Boolean)


29
30
31
# File 'lib/timeout_cache.rb', line 29

def expired?
  @expires_at <= Time.now
end