Class: Hx::Cache::Record

Inherits:
Object
  • Object
show all
Defined in:
lib/hx.rb

Instance Method Summary collapse

Constructor Details

#initializeRecord

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

Raises:



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_pathsObject



258
259
260
# File 'lib/hx.rb', line 258

def get_entry_paths
  @paths || (@paths = yield)
end