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.
236 237 238 239 |
# File 'lib/hx.rb', line 236 def initialize @paths = nil @entries = {} end |
Instance Method Details
#clear_path(path) ⇒ Object
241 242 243 244 |
# File 'lib/hx.rb', line 241 def clear_path(path) @paths = nil @entries.delete path end |
#get_entry(path) ⇒ Object
250 251 252 253 254 255 256 257 258 259 260 261 262 263 |
# File 'lib/hx.rb', line 250 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
246 247 248 |
# File 'lib/hx.rb', line 246 def get_entry_paths @paths || (@paths = yield) end |