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.



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

Raises:



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_pathsObject



246
247
248
# File 'lib/hx.rb', line 246

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