diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-19 14:40:06 -0800 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2015-02-23 10:14:04 -0800 |
commit | 30520d738a3683b15a70d43dd9cf1aa3da61686d (patch) | |
tree | c4b12e272e54d52f35f4123be1067afb4b78f5fc /lib/chef/resource.rb | |
parent | a7f5c92960aedf8d5bfc71abbce430ab075e016a (diff) | |
download | chef-30520d738a3683b15a70d43dd9cf1aa3da61686d.tar.gz |
nillable deploy resource + nillable LWRP args
introduced nillable_set_or_return so that we can actually set a nil value
on a resource from the DSL.
this fixes the case where you want to do (and we document) setting
symlink_before_migrate to nil on the deploy resource.
to implement this better also moved up the attribute DSL method to the
base Chef::Resource class.
all LWRP resources are now nillable as well.
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r-- | lib/chef/resource.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index ea220b6c70..2df73a52e8 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -997,6 +997,15 @@ class Chef end # + # DSL method used to define attribute on a resource wrapping params_validate + # + def self.attribute(attr_name, validation_opts={}) + define_method(attr_name) do |arg=NULL_ARG| + nillable_set_or_return(attr_name.to_sym, arg, validation_opts) + end + end + + # # The cookbook in which this Resource was defined (if any). # # @return Chef::CookbookVersion The cookbook in which this Resource was defined. |