Class: JekyllIncludeCache::Cache
- Inherits:
-
Object
- Object
- JekyllIncludeCache::Cache
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll-include-cache/cache.rb
Instance Method Summary collapse
- #[](key) ⇒ Object
- #getset(key) ⇒ Object
-
#initialize(_name = nil) ⇒ Cache
constructor
A new instance of Cache.
Constructor Details
#initialize(_name = nil) ⇒ Cache
Returns a new instance of Cache.
10 11 12 |
# File 'lib/jekyll-include-cache/cache.rb', line 10 def initialize(_name = nil) @cache = {} end |
Instance Method Details
#[](key) ⇒ Object
24 25 26 27 28 29 30 |
# File 'lib/jekyll-include-cache/cache.rb', line 24 def [](key) if key?(key) @cache[key] else raise end end |
#getset(key) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/jekyll-include-cache/cache.rb', line 14 def getset(key) if key?(key) @cache[key] else value = yield @cache[key] = value value end end |