Class: Puppet::Provider::A2mod

Inherits:
Puppet::Provider
  • Object
show all
Defined in:
lib/puppet/provider/a2mod.rb

Overview

a2mod.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.prefetch(mods) ⇒ Object

Fetches the mod provider



6
7
8
9
10
11
# File 'lib/puppet/provider/a2mod.rb', line 6

def self.prefetch(mods)
  instances.each do |prov|
    mod = mods[prov.name]
    mod.provider = prov if mod
  end
end

Instance Method Details

#exists?Boolean

Return’s if the ensure property is absent or not

Returns:

  • (Boolean)


36
37
38
# File 'lib/puppet/provider/a2mod.rb', line 36

def exists?
  properties[:ensure] != :absent
end

#flushObject

Clear’s the property_hash



14
15
16
# File 'lib/puppet/provider/a2mod.rb', line 14

def flush
  @property_hash.clear
end

#propertiesObject

Returns a copy of the property_hash



19
20
21
22
23
24
25
# File 'lib/puppet/provider/a2mod.rb', line 19

def properties
  if @property_hash.empty?
    @property_hash = query || { ensure: :absent }
    @property_hash[:ensure] = :absent if @property_hash.empty?
  end
  @property_hash.dup
end

#queryObject

Returns the properties of the given mod if it exists.



28
29
30
31
32
33
# File 'lib/puppet/provider/a2mod.rb', line 28

def query
  self.class.instances.each do |mod|
    return mod.properties if mod.name == name || mod.name.downcase == name
  end
  nil
end