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



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

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

Instance Method Details

#exists?Boolean

Return’s if the ensure property is absent or not

Returns:

  • (Boolean)


38
39
40
# File 'lib/puppet/provider/a2mod.rb', line 38

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
34
35
# File 'lib/puppet/provider/a2mod.rb', line 28

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