Class: N::App::Fragment
- Inherits:
-
Object
- Object
- N::App::Fragment
- Includes:
- Expirable, LRUCache::Item
- Defined in:
- lib/n/app/fragment.rb
Constant Summary collapse
- ADMIN_FLAG =
precompiled flags for fragment key “customization”
"-a"
- OWNER_FLAG =
"-o"
- EDITOR_FLAG =
"-e"
- VIEWER_FLAG =
"-f"
- MY_FLAG =
"-m"
- ANONYMOUS_FLAG =
"-n"
Instance Attribute Summary collapse
-
#body ⇒ Object
Returns the value of attribute body.
-
#expires ⇒ Object
another method for invalidation, allows for more flexible invalidation strategies.
-
#lm ⇒ Object
Returns the value of attribute lm.
Attributes included from LRUCache::Item
#lru_key, #lru_next, #lru_prev
Instance Method Summary collapse
- #expired? ⇒ Boolean
- #expires_after!(ea = (60*60*24)) ⇒ Object
-
#initialize(body = "", lm = Time.now) ⇒ Fragment
constructor
A new instance of Fragment.
- #to_str ⇒ Object
Methods included from Expirable
#expires_after, #expires_spread
Constructor Details
#initialize(body = "", lm = Time.now) ⇒ Fragment
Returns a new instance of Fragment.
49 50 51 52 |
# File 'lib/n/app/fragment.rb', line 49 def initialize(body = "", lm = Time.now) @body = body @lm = lm end |
Instance Attribute Details
#body ⇒ Object
Returns the value of attribute body.
42 43 44 |
# File 'lib/n/app/fragment.rb', line 42 def body @body end |
#expires ⇒ Object
another method for invalidation, allows for more flexible invalidation strategies. also used by the legacy autoinvalidate code.
47 48 49 |
# File 'lib/n/app/fragment.rb', line 47 def expires @expires end |
#lm ⇒ Object
Returns the value of attribute lm.
42 43 44 |
# File 'lib/n/app/fragment.rb', line 42 def lm @lm end |
Instance Method Details
#expired? ⇒ Boolean
58 59 60 |
# File 'lib/n/app/fragment.rb', line 58 def expired? return true if @expires.nil? || (Time.now > @expires) end |
#expires_after!(ea = (60*60*24)) ⇒ Object
54 55 56 |
# File 'lib/n/app/fragment.rb', line 54 def expires_after!(ea = (60*60*24)) @expires = @lm + ea end |
#to_str ⇒ Object
62 63 64 |
# File 'lib/n/app/fragment.rb', line 62 def to_str return @body end |