Class: Apnotic::InstanceCache
- Inherits:
-
Object
- Object
- Apnotic::InstanceCache
- Defined in:
- lib/apnotic/instance_cache.rb
Instance Method Summary collapse
- #call ⇒ Object
-
#initialize(instance, method, ttl) ⇒ InstanceCache
constructor
A new instance of InstanceCache.
Constructor Details
#initialize(instance, method, ttl) ⇒ InstanceCache
Returns a new instance of InstanceCache.
3 4 5 6 7 |
# File 'lib/apnotic/instance_cache.rb', line 3 def initialize(instance, method, ttl) @instance = instance @method = method @ttl = ttl end |
Instance Method Details
#call ⇒ Object
9 10 11 12 13 14 15 |
# File 'lib/apnotic/instance_cache.rb', line 9 def call if @cached_value && !expired? @cached_value else new_value end end |