Module: PuppetX::FileMapper

Defined in:
lib/puppetx/filemapper.rb

Defined Under Namespace

Modules: ClassMethods

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



47
48
49
50
51
# File 'lib/puppetx/filemapper.rb', line 47

def self.included(klass)
  klass.extend PuppetX::FileMapper::ClassMethods
  klass.mk_property_methods
  klass.initvars
end

Instance Method Details

#createObject

Copy all desired resource properties into this resource for generation upon flush

This method is necessary for the provider to be ensurable

Raises:

  • (Puppet::Error)


10
11
12
13
14
15
16
# File 'lib/puppetx/filemapper.rb', line 10

def create
  raise Puppet::Error, "#{self.class} is in an error state" if self.class.failed?
  @resource.class.validproperties.each do |property|
    @property_hash[property] = @resource.should(property) if @resource.should(property)
  end
  dirty!
end

#destroyObject

Update the property hash to mark this resource as absent for flushing

This method is necessary for the provider to be ensurable



30
31
32
33
# File 'lib/puppetx/filemapper.rb', line 30

def destroy
  @property_hash[:ensure] = :absent
  dirty!
end

#dirty!Object

Mark the file associated with this resource as dirty



36
37
38
39
# File 'lib/puppetx/filemapper.rb', line 36

def dirty!
  file = select_file
  self.class.dirty_file!(file)
end

#exists?TrueClass || FalseClass

Use the prefetched status to determine of the resource exists.

This method is necessary for the provider to be ensurable

Returns:

  • (TrueClass || FalseClass)


23
24
25
# File 'lib/puppetx/filemapper.rb', line 23

def exists?
  @property_hash[:ensure] && @property_hash[:ensure] == :present
end

#flushObject

When processing on this resource is complete, trigger a flush on the file that this resource belongs to.



43
44
45
# File 'lib/puppetx/filemapper.rb', line 43

def flush
  self.class.flush_file(select_file)
end