Class: OsCtl::Lib::Zfs::DatasetCache

Inherits:
Object
  • Object
show all
Defined in:
lib/libosctl/zfs/dataset_cache.rb

Instance Method Summary collapse

Constructor Details

#initialize(datasets) ⇒ DatasetCache

Returns a new instance of DatasetCache.

Parameters:



4
5
6
7
# File 'lib/libosctl/zfs/dataset_cache.rb', line 4

def initialize(datasets)
  @index = {}
  rebuild_index(datasets)
end

Instance Method Details

#[](name) ⇒ Zfs::Dataset?

Parameters:

  • name (String)

Returns:



11
12
13
# File 'lib/libosctl/zfs/dataset_cache.rb', line 11

def [](name)
  @index[name]
end

#rebuild_index(datasets) ⇒ Object (protected)



17
18
19
20
# File 'lib/libosctl/zfs/dataset_cache.rb', line 17

def rebuild_index(datasets)
  @index.clear
  datasets.each { |ds| @index[ds.name] = ds }
end