diff options
author | John Keiser <john@johnkeiser.com> | 2015-06-23 12:04:19 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-06-23 12:04:19 -0700 |
commit | 35e07bb402a215389eb674045cec78364a64a779 (patch) | |
tree | 36e99a8bb2d67720cf3c000769c1649b2fa14ea8 /lib/chef | |
parent | 87e631c3f0b8c440044e2e85a084b3bfc221cbed (diff) | |
download | chef-35e07bb402a215389eb674045cec78364a64a779.tar.gz |
Get rid of warning when defining an LWRPjk/remove_lwrp_warning
Diffstat (limited to 'lib/chef')
-rw-r--r-- | lib/chef/resource.rb | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 418b0dc1ce..ed0dbb50a7 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -1318,23 +1318,22 @@ class Chef # when Chef::Resource::MyLwrp # end # - resource_subclass = class_eval <<-EOM, __FILE__, __LINE__+1 - class Chef::Resource::#{class_name} < resource_class - resource_name nil # we do not actually provide anything - def initialize(*args, &block) - Chef::Log.deprecation("Using an LWRP by its name (#{class_name}) directly is no longer supported in Chef 13 and will be removed. Use Chef::Resource.resource_for_node(node, name) instead.") + resource_subclass = Class.new(resource_class) do + resource_name nil # we do not actually provide anything + def initialize(*args, &block) + Chef::Log.deprecation("Using an LWRP by its name (#{self.class.name}) directly is no longer supported in Chef 13 and will be removed. Use Chef::Resource.resource_for_node(node, name) instead.") + super + end + def self.resource_name(*args) + if args.empty? + @resource_name ||= superclass.resource_name + else super end - def self.resource_name(*args) - if args.empty? - @resource_name ||= superclass.resource_name - else - super - end - end - self end - EOM + self + end + eval("Chef::Resource::#{class_name} = resource_subclass") # Make case, is_a and kind_of work with the new subclass, for backcompat. # Any subclass of Chef::Resource::ResourceClass is already a subclass of resource_class # Any subclass of resource_class is considered a subclass of Chef::Resource::ResourceClass |