Class: Hx::Cache::Record
- Inherits:
-
Object
- Object
- Hx::Cache::Record
- Defined in:
- lib/hx.rb
Instance Method Summary collapse
- #clear_path(path) ⇒ Object
- #get_entry(path) ⇒ Object
- #get_entry_paths ⇒ Object
-
#initialize ⇒ Record
constructor
A new instance of Record.
Constructor Details
#initialize ⇒ Record
Returns a new instance of Record.
248 249 250 251 |
# File 'lib/hx.rb', line 248 def initialize @paths = nil @entries = {} end |
Instance Method Details
#clear_path(path) ⇒ Object
253 254 255 256 |
# File 'lib/hx.rb', line 253 def clear_path(path) @paths = nil @entries.delete path end |
#get_entry(path) ⇒ Object
262 263 264 265 266 267 268 269 270 271 272 273 274 275 |
# File 'lib/hx.rb', line 262 def get_entry(path) begin entry = @entries.fetch(path) rescue IndexError begin entry = yield rescue NoSuchEntryError entry = nil end @entries[path] = entry end raise NoSuchEntryError, path unless entry entry end |
#get_entry_paths ⇒ Object
258 259 260 |
# File 'lib/hx.rb', line 258 def get_entry_paths @paths || (@paths = yield) end |