diff options
author | John Keiser <john@johnkeiser.com> | 2015-05-07 16:24:45 -0700 |
---|---|---|
committer | John Keiser <john@johnkeiser.com> | 2015-05-13 13:43:15 -0700 |
commit | 146f0809c1912988751688fff2ef6945c90a4513 (patch) | |
tree | 96e6ac327717318984930b84f69d8690a78b631c /lib/chef/provider.rb | |
parent | 0700ce4cd87825c6a925036ad5143ceb79438d38 (diff) | |
download | chef-146f0809c1912988751688fff2ef6945c90a4513.tar.gz |
Deprecate Chef::Provider::LwrpClass the same way we did Resource
Diffstat (limited to 'lib/chef/provider.rb')
-rw-r--r-- | lib/chef/provider.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/chef/provider.rb b/lib/chef/provider.rb index 65a56cf726..3ab4d4d2b1 100644 --- a/lib/chef/provider.rb +++ b/lib/chef/provider.rb @@ -191,5 +191,33 @@ class Chef end end + module DeprecatedLWRPClass + def const_missing(class_name) + if deprecated_constants[class_name.to_sym] + Chef::Log.deprecation("Using an LWRP provider by its name (#{class_name}) directly is no longer supported in Chef 12 and will be removed. Use Chef::ProviderResolver.new(node, resource, action) instead.") + deprecated_constants[class_name.to_sym] + else + raise NameError, "uninitialized constant Chef::Provider::#{class_name}" + end + end + + # @api private + def register_deprecated_lwrp_class(provider_class, class_name) + # Register Chef::Provider::MyProvider with deprecation warnings if you + # try to access it + if Chef::Provider.const_defined?(class_name, false) + Chef::Log.warn "Chef::Provider::#{class_name} already exists! Cannot create deprecation class for #{provider_class}" + else + deprecated_constants[class_name.to_sym] = provider_class + end + end + + private + + def deprecated_constants + @deprecated_constants ||= {} + end + end + extend DeprecatedLWRPClass end end |