diff options
-rw-r--r-- | lib/chef/provider.rb | 4 | ||||
-rw-r--r-- | lib/chef/resource.rb | 15 | ||||
-rw-r--r-- | lib/chef/resource/action_provider.rb | 2 |
3 files changed, 15 insertions, 6 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index b9b9ac8126..f2a493c3e6 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -193,6 +193,10 @@ class Chef # @return [Boolean] whether the block was executed. # def converge_if_changed(*properties, &converge_block) + if !converge_block + raise ArgumentError, "converge_if_changed must be passed a block!" + end + properties = new_resource.class.state_properties.map { |p| p.name } if properties.empty? properties = properties.map { |p| p.to_sym } if current_resource diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 39fd05305f..b9c074117f 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -2,7 +2,7 @@ # Author:: Adam Jacob (<adam@opscode.com>) # Author:: Christopher Walters (<cw@opscode.com>) # Author:: John Keiser (<jkeiser@chef.io) -# Copyright:: Copyright (c) 2008-2015 Opscode, Inc. +# Copyright:: Copyright (c) 2008-2015 Chef, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -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 |