Expirable

Generic expirability mixin.

Attributes

expires[RW]

Public Instance Methods

expired?() click to toggle source

Is this entry expired?

    # File lib/more/facets/expirable.rb, line 40
40:   def expired?
41:     if @expires.nil? or (Time.now > @expires)
42:       return true
43:     else
44:       return false
45:     end
46:   end
expires_after(timeout = (60*60*24)) click to toggle source

Set the expires timeout for this entry.

    # File lib/more/facets/expirable.rb, line 27
27:   def expires_after(timeout = (60*60*24))
28:     @expires = Time.now + timeout
29:   end
expires_spread(base, spread) click to toggle source

Set the expire timeout for this entry. The timeout happens after (base + rand(spread)) seconds.

    # File lib/more/facets/expirable.rb, line 34
34:   def expires_spread(base, spread)
35:     @expires = Time.now + base + rand(spread)
36:   end
touch!() click to toggle source

Update the expiration period. Override in your application.

    # File lib/more/facets/expirable.rb, line 50
50:   def touch!
51:   end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.