Class: OsCtl::Lib::Zfs::DatasetCache
- Inherits:
-
Object
- Object
- OsCtl::Lib::Zfs::DatasetCache
- Defined in:
- lib/libosctl/zfs/dataset_cache.rb
Instance Method Summary collapse
- #[](name) ⇒ Zfs::Dataset?
-
#initialize(datasets) ⇒ DatasetCache
constructor
A new instance of DatasetCache.
- #rebuild_index(datasets) ⇒ Object protected
Constructor Details
#initialize(datasets) ⇒ DatasetCache
Returns a new instance of DatasetCache.
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?
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 |