Class: TimeoutCache::TimedObject
- Inherits:
-
Object
- Object
- TimeoutCache::TimedObject
- Defined in:
- lib/timeout_cache.rb
Overview
Wraps an object by attaching a time to it.
Instance Attribute Summary collapse
-
#expires_at ⇒ Object
readonly
:nodoc:.
-
#value ⇒ Object
readonly
:nodoc:.
Instance Method Summary collapse
-
#expired? ⇒ Boolean
Returns true if the object has expired.
-
#initialize(value, time) ⇒ TimedObject
constructor
A new instance of TimedObject.
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_at ⇒ Object (readonly)
:nodoc:
20 21 22 |
# File 'lib/timeout_cache.rb', line 20 def expires_at @expires_at end |
#value ⇒ Object (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.
29 30 31 |
# File 'lib/timeout_cache.rb', line 29 def expired? @expires_at <= Time.now end |