Expirable
Generic expirability mixin.
Methods
expired?
expires_after
expires_spread
touch!
Attributes
[RW] | expires |
Public Instance methods
Is this entry expired?
[ + ]
# File lib/more/facets/expirable.rb, line 45 def expired? if @expires.nil? or (Time.now > @expires) return true else return false end end
Set the expires timeout for this entry.
[ + ]
# File lib/more/facets/expirable.rb, line 32 def expires_after(timeout = (60*60*24)) @expires = Time.now + timeout end
Set the expire timeout for this entry. The timeout happens after (base + rand(spread)) seconds.
[ + ]
# File lib/more/facets/expirable.rb, line 39 def expires_spread(base, spread) @expires = Time.now + base + rand(spread) end
Update the expiration period. Override in your application.
[ + ]
# File lib/more/facets/expirable.rb, line 55 def touch! end