Class: CFA::AugeasKeysCache

Inherits:
Object
  • Object
show all
Defined in:
lib/cfa/augeas_parser/keys_cache.rb

Overview

A cache that holds all avaiable keys in an Augeas tree. It is used to prevent too many ‘aug.match` calls which are expensive.

Instance Method Summary collapse

Constructor Details

#initialize(aug, prefix) ⇒ AugeasKeysCache

initialize cache from passed Augeas object

Parameters:

  • aug (::Augeas)
  • prefix (String)

    Augeas path for which cache should be created



8
9
10
# File 'lib/cfa/augeas_parser/keys_cache.rb', line 8

def initialize(aug, prefix)
  fill_cache(aug, prefix)
end

Instance Method Details

#keys_for_prefix(prefix) ⇒ Object

Returns list of keys available on given prefix.

Returns:

  • list of keys available on given prefix



13
14
15
# File 'lib/cfa/augeas_parser/keys_cache.rb', line 13

def keys_for_prefix(prefix)
  @cache[prefix] || []
end