Class: JekyllHTTPRequest::Cache
- Inherits:
-
Object
- Object
- JekyllHTTPRequest::Cache
- Extended by:
- Forwardable
- Defined in:
- lib/jekyll-http-request/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.
11 12 13 |
# File 'lib/jekyll-http-request/cache.rb', line 11 def initialize(_name = nil) @cache = {} end |
Instance Method Details
#[](key) ⇒ Object
25 26 27 28 29 30 31 |
# File 'lib/jekyll-http-request/cache.rb', line 25 def [](key) if key?(key) @cache[key] else raise end end |
#getset(key) ⇒ Object
15 16 17 18 19 20 21 22 23 |
# File 'lib/jekyll-http-request/cache.rb', line 15 def getset(key) if key?(key) @cache[key] else value = yield @cache[key] = value value end end |