Class: ESI::Fragment
- Inherits:
-
Object
- Object
- ESI::Fragment
- Defined in:
- lib/esi/cache.rb
Overview
Represents part of the cached page, typically an <esi:include
Instance Attribute Summary collapse
-
#body ⇒ Object
(also: #read_body)
Returns the value of attribute body.
-
#max_age ⇒ Object
Returns the value of attribute max_age.
-
#uri ⇒ Object
Returns the value of attribute uri.
Instance Method Summary collapse
-
#dup ⇒ Object
make a copy of the object, necessary for thread safety.
-
#initialize(uri, max_age, body) ⇒ Fragment
constructor
A new instance of Fragment.
-
#valid? ⇒ Boolean
determine if the fragment is still valid, given the max age associated when the object was created.
Constructor Details
#initialize(uri, max_age, body) ⇒ Fragment
Returns a new instance of Fragment.
15 16 17 18 19 |
# File 'lib/esi/cache.rb', line 15 def initialize(uri,max_age,body) @uri = uri @max_age = Time.now.to_i + max_age.to_i @body = body end |
Instance Attribute Details
#body ⇒ Object Also known as: read_body
Returns the value of attribute body.
12 13 14 |
# File 'lib/esi/cache.rb', line 12 def body @body end |
#max_age ⇒ Object
Returns the value of attribute max_age.
12 13 14 |
# File 'lib/esi/cache.rb', line 12 def max_age @max_age end |
#uri ⇒ Object
Returns the value of attribute uri.
12 13 14 |
# File 'lib/esi/cache.rb', line 12 def uri @uri end |
Instance Method Details
#dup ⇒ Object
make a copy of the object, necessary for thread safety
22 23 24 |
# File 'lib/esi/cache.rb', line 22 def dup Fragment.new( @uri, @max_age, @body ) end |
#valid? ⇒ Boolean
determine if the fragment is still valid, given the max age associated when the object was created
27 28 29 |
# File 'lib/esi/cache.rb', line 27 def valid? (Time.now.to_i < @max_age) end |