Method: Puppet::Type#currentpropvalues

Defined in:
lib/puppet/type.rb

#currentpropvaluesHash{Puppet::Property => Object}

Returns a hash of the current properties and their values. If a resource is absent, its value is the symbol ‘:absent`



1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
# File 'lib/puppet/type.rb', line 1112

def currentpropvalues
  # It's important to use the 'properties' method here, as it follows the order
  # in which they're defined in the class.  It also guarantees that 'ensure'
  # is the first property, which is important for skipping 'retrieve' on
  # all the properties if the resource is absent.
  ensure_state = false
  properties.each_with_object({}) do |property, prophash|
    if property.name == :ensure
      ensure_state = property.retrieve
      prophash[property] = ensure_state
    elsif ensure_state == :absent
      prophash[property] = :absent
    else
      prophash[property] = property.retrieve
    end
  end
end