summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Keiser <john@johnkeiser.com>2015-07-30 19:49:42 -0600
committerJohn Keiser <john@johnkeiser.com>2015-07-30 19:49:42 -0600
commit7707d5cd5f23e986ac389950f8b9182da62214bf (patch)
treeea6cad3f55c3c7c78ee4480c13d4d30ce1038ddd
parent241030ea61eedaaa05314b4b098faf2707fdf642 (diff)
downloadchef-jk/converge_if_changed.tar.gz
Move current_value_does_not_exist! directly on Resourcejk/converge_if_changed
-rw-r--r--lib/chef/resource.rb13
-rw-r--r--lib/chef/resource/action_provider.rb2
2 files changed, 10 insertions, 5 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 39fd05305f..7dff32ab5b 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -1385,14 +1385,17 @@ class Chef
# created resource with its identity values filled in.
#
def self.load_current_value(&load_block)
- include LoadCurrentValueDSL
define_method(:load_current_value!, &load_block)
end
- module LoadCurrentValueDSL
- def current_value_does_not_exist!
- raise Chef::Exceptions::CurrentValueDoesNotExist
- end
+ #
+ # Call this in `load_current_value` to indicate that the value does not
+ # exist and that `current_resource` should therefore be `nil`.
+ #
+ # @raise Chef::Exceptions::CurrentValueDoesNotExist
+ #
+ def current_value_does_not_exist!
+ raise Chef::Exceptions::CurrentValueDoesNotExist
end
#
diff --git a/lib/chef/resource/action_provider.rb b/lib/chef/resource/action_provider.rb
index abbab79311..d71b54ef4d 100644
--- a/lib/chef/resource/action_provider.rb
+++ b/lib/chef/resource/action_provider.rb
@@ -41,6 +41,8 @@ class Chef
# Call the actual load_current_value! method. If it raises
# CurrentValueDoesNotExist, set current_resource to `nil`.
begin
+ # If the user specifies load_current_value do |desired_resource|, we
+ # pass in the desired resource as well as the current one.
if current_resource.method(:load_current_value!).arity > 0
current_resource.load_current_value!(new_resource)
else