From 7707d5cd5f23e986ac389950f8b9182da62214bf Mon Sep 17 00:00:00 2001 From: John Keiser Date: Thu, 30 Jul 2015 19:49:42 -0600 Subject: Move current_value_does_not_exist! directly on Resource --- lib/chef/resource.rb | 13 ++++++++----- lib/chef/resource/action_provider.rb | 2 ++ 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 -- cgit v1.2.1