diff options
author | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-21 08:13:47 -0700 |
---|---|---|
committer | Lamont Granquist <lamont@scriptkiddie.org> | 2017-03-21 08:13:47 -0700 |
commit | a65147034050361a8b2bf80a54a2532bf9f0413d (patch) | |
tree | feb2dbd85edca4c3e1d8d1f555422ed1f7852e53 /lib/chef/dsl | |
parent | b39d1b2937d7f6b2b974531f99b60e7b5d026fc7 (diff) | |
download | chef-a65147034050361a8b2bf80a54a2532bf9f0413d.tar.gz |
Chef-13: remove method_missing from the DSL
Signed-off-by: Lamont Granquist <lamont@scriptkiddie.org>
Diffstat (limited to 'lib/chef/dsl')
-rw-r--r-- | lib/chef/dsl/method_missing.rb | 75 | ||||
-rw-r--r-- | lib/chef/dsl/recipe.rb | 5 |
2 files changed, 1 insertions, 79 deletions
diff --git a/lib/chef/dsl/method_missing.rb b/lib/chef/dsl/method_missing.rb deleted file mode 100644 index 2917a54ee8..0000000000 --- a/lib/chef/dsl/method_missing.rb +++ /dev/null @@ -1,75 +0,0 @@ -#-- -# Copyright:: Copyright 2008-2016 Chef Software, Inc. -# License:: Apache License, Version 2.0 -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -class Chef - module DSL - # @deprecated scheduled to die in a Chef 13 fire - module MethodMissing - def describe_self_for_error - if respond_to?(:name) - %Q{`#{self.class} "#{name}"'} - elsif respond_to?(:recipe_name) - %Q{`#{self.class} "#{recipe_name}"'} - else - to_s - end - end - - # DEPRECATED: - # method_missing must live for backcompat purposes until Chef 13. - def method_missing(method_symbol, *args, &block) - # - # If there is already DSL for this, someone must have called - # method_missing manually. Not a fan. Not. A. Fan. - # - if respond_to?(method_symbol) - Chef.deprecated(:internal_api, "Calling method_missing(#{method_symbol.inspect}) directly is deprecated in Chef 12 and will be removed in Chef 13. Use public_send() or send() instead.") - return send(method_symbol, *args, &block) - end - - # - # If a definition exists, then Chef::DSL::Definitions.add_definition was - # never called. DEPRECATED. - # - if run_context.definitions.has_key?(method_symbol.to_sym) - Chef.deprecated(:internal_api, "Definition #{method_symbol} (#{run_context.definitions[method_symbol.to_sym]}) was added to the run_context without calling Chef::DSL::Definitions.add_definition(#{method_symbol.to_sym.inspect}). This will become required in Chef 13.") - Chef::DSL::Definitions.add_definition(method_symbol) - return send(method_symbol, *args, &block) - end - - # - # See if the resource exists anyway. If the user had set - # Chef::Resource::Blah = <resource>, a deprecation warning will be - # emitted and the DSL method 'blah' will be added to the DSL. - # - resource_class = Chef::ResourceResolver.resolve(method_symbol, node: run_context ? run_context.node : nil) - if resource_class - Chef::DSL::Resources.add_resource_dsl(method_symbol) - return send(method_symbol, *args, &block) - end - - begin - super - rescue NoMethodError - raise NoMethodError, "No resource or method named `#{method_symbol}' for #{describe_self_for_error}" - rescue NameError - raise NameError, "No resource, method, or local variable named `#{method_symbol}' for #{describe_self_for_error}" - end - end - end - end -end diff --git a/lib/chef/dsl/recipe.rb b/lib/chef/dsl/recipe.rb index e2bd070179..dedf291857 100644 --- a/lib/chef/dsl/recipe.rb +++ b/lib/chef/dsl/recipe.rb @@ -1,7 +1,7 @@ #-- # Author:: Adam Jacob (<adam@chef.io>) # Author:: Christopher Walters (<cw@chef.io>) -# Copyright:: Copyright 2008-2016 Chef Software, Inc. +# Copyright:: Copyright 2008-2017, Chef Software Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -27,7 +27,6 @@ require "chef/dsl/reboot_pending" require "chef/dsl/audit" require "chef/dsl/powershell" require "chef/dsl/core" -require "chef/dsl/method_missing" require "chef/mixin/lazy_module_include" class Chef @@ -60,8 +59,6 @@ class Chef include Chef::DSL::Powershell include Chef::DSL::Resources include Chef::DSL::Definitions - # method_missing will disappear in Chef 13 - include Chef::DSL::MethodMissing extend Chef::Mixin::LazyModuleInclude def resource_class_for(snake_case_name) |