diff options
author | John Keiser <john@johnkeiser.com> | 2015-07-06 13:04:46 -0600 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-07-06 13:04:46 -0600 |
commit | 2408528f13ce5b47c18f0db4c6b6d3cf58d25c0a (patch) | |
tree | 9243002f6b6d294e4f1bb21a4bc714c9d577c1a1 /lib/chef/dsl | |
parent | cb163f4b69e0378b9dc4c60b935b891e05706ccc (diff) | |
download | chef-2408528f13ce5b47c18f0db4c6b6d3cf58d25c0a.tar.gz |
Deprecate passing more than 1 argument to create a resourcejk/3634
Diffstat (limited to 'lib/chef/dsl')
-rw-r--r-- | lib/chef/dsl/resources.rb | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/chef/dsl/resources.rb b/lib/chef/dsl/resources.rb index c634c6520d..f15beaeab0 100644 --- a/lib/chef/dsl/resources.rb +++ b/lib/chef/dsl/resources.rb @@ -10,14 +10,16 @@ class Chef def self.add_resource_dsl(dsl_name) begin module_eval(<<-EOM, __FILE__, __LINE__+1) - def #{dsl_name}(name=nil, &block) - declare_resource(#{dsl_name.inspect}, name, caller[0], &block) + def #{dsl_name}(*args, &block) + Chef::Log.deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (\#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: \#{args}") if args.size > 1 + declare_resource(#{dsl_name.inspect}, args[0], caller[0], &block) end EOM rescue SyntaxError # Handle the case where dsl_name has spaces, etc. - define_method(dsl_name.to_sym) do |name=nil, &block| - declare_resource(dsl_name, name, caller[0], &block) + define_method(dsl_name.to_sym) do |*args, &block| + Chef::Log.deprecation("Cannot create resource #{dsl_name} with more than one argument. All arguments except the name (#{args[0].inspect}) will be ignored. This will cause an error in Chef 13. Arguments: #{args}") if args.size > 1 + declare_resource(dsl_name, args[0], caller[0], &block) end end end |