diff options
author | Prajakta Purohit <prajakta@opscode.com> | 2016-06-09 05:59:33 -0700 |
---|---|---|
committer | Prajakta Purohit <prajakta@opscode.com> | 2016-06-09 06:04:55 -0700 |
commit | 7c389230c75e4147de0e8600fb597301eae28e5f (patch) | |
tree | a25fcf016cf37ad6f3f81bc74f9fd742e951d877 /lib/chef/resource.rb | |
parent | 8ed24be9cc9836c2158ef23f35fe0cca871555e2 (diff) | |
download | chef-7c389230c75e4147de0e8600fb597301eae28e5f.tar.gz |
no more missing constants for LWRP classpraj/FLOW-927/s3cmd
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r-- | lib/chef/resource.rb | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb index 2633187690..262aa84781 100644 --- a/lib/chef/resource.rb +++ b/lib/chef/resource.rb @@ -1530,23 +1530,6 @@ class Chef end # @api private - def self.register_deprecated_lwrp_class(resource_class, class_name) - if Chef::Resource.const_defined?(class_name, false) - Chef::Log.warn "#{class_name} already exists! Deprecation class overwrites #{resource_class}" - Chef::Resource.send(:remove_const, class_name) - end - - if !Chef::Config[:treat_deprecation_warnings_as_errors] - Chef::Resource.const_set(class_name, resource_class) - deprecated_constants[class_name.to_sym] = resource_class - end - end - - def self.deprecated_constants - @deprecated_constants ||= {} - end - - # @api private def lookup_provider_constant(name, action = :nothing) begin self.class.provider_base.const_get(convert_to_class_name(name.to_s)) @@ -1559,6 +1542,27 @@ class Chef end end + module DeprecatedLWRPClass + + # @api private + def register_deprecated_lwrp_class(resource_class, class_name) + if Chef::Resource.const_defined?(class_name, false) + Chef::Log.warn "#{class_name} already exists! Deprecation class overwrites #{resource_class}" + Chef::Resource.send(:remove_const, class_name) + end + + if !Chef::Config[:treat_deprecation_warnings_as_errors] + Chef::Resource.const_set(class_name, resource_class) + Chef::Resource.deprecated_constants[class_name.to_sym] = resource_class + end + end + + def deprecated_constants + raise "Deprecated constants should be called only on Chef::Resource" unless self == Chef::Resource + @deprecated_constants ||= {} + end + end + private def self.remove_canonical_dsl @@ -1569,6 +1573,7 @@ class Chef end end end + extend DeprecatedLWRPClass end end |