summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorLuke Kanies <luke@madstop.com>2008-09-30 22:04:38 -0500
committerLuke Kanies <luke@madstop.com>2008-09-30 22:04:38 -0500
commitee579641f72b399e9e13e989a7779b533004b634 (patch)
tree16d36d14f5376e3863f0c928b01346d5a2c54088 /lib
parent0fb4693f748cd3516ed36af19d70885153b43b11 (diff)
downloadpuppet-ee579641f72b399e9e13e989a7779b533004b634.tar.gz
puppet-ee579641f72b399e9e13e989a7779b533004b634.tar.xz
puppet-ee579641f72b399e9e13e989a7779b533004b634.zip
Modified the behaviour of resource-level 'retrieve' -- it only
calls 'retrieve' on each property if the resource exists. Signed-off-by: Luke Kanies <luke@madstop.com>
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/type.rb24
1 files changed, 17 insertions, 7 deletions
diff --git a/lib/puppet/type.rb b/lib/puppet/type.rb
index c7a866e2c..1989fc057 100644
--- a/lib/puppet/type.rb
+++ b/lib/puppet/type.rb
@@ -906,14 +906,24 @@ class Type
# get a hash of the current properties.
def currentpropvalues(override_value = nil)
- # it's important to use the method here, as it follows the order
- # in which they're defined in the object
+ # it's important to use the 'properties' method here, as it follows the order
+ # in which they're defined in the object. 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
return properties().inject({}) { | prophash, property|
- prophash[property] = override_value.nil? ?
- property.retrieve :
- override_value
- prophash
- }
+ if property.name == :ensure
+ ensure_state = property.retrieve
+ prophash[property] = ensure_state
+ else
+ if ensure_state == :absent
+ prophash[property] = :absent
+ else
+ prophash[property] = property.retrieve
+ end
+ end
+ prophash
+ }
end
# Are we running in noop mode?