Module: Expirable

Module | Expirable
In: | lib/more/facets/expirable.rb

Generic expirability mixin.

### Methods

expired? expires_after expires_spread touch!

### Attributes

expires | [RW] |

### Public Instance methods

expired?()

Is this entry expired?

[Source]

    # File lib/more/facets/expirable.rb, line 40
      def expired?
        if @expires.nil? or (Time.now > @expires)
          return true
        else
          return false
        end
      end

expires_after(timeout = (60*60*24))

Set the expires timeout for this entry.

[Source]

    # File lib/more/facets/expirable.rb, line 27
      def expires_after(timeout = (60*60*24))
        @expires = Time.now + timeout
      end

expires_spread(base, spread)

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

[Source]

    # File lib/more/facets/expirable.rb, line 34
      def expires_spread(base, spread)
        @expires = Time.now + base + rand(spread)
      end

touch!()

Update the expiration period. Override in your application.

[Source]

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

[Validate]