diff options
Diffstat (limited to 'lib/chef/resource.rb')
-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 |