summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Davis <ryand-ruby@zenspider.com>2020-03-06 17:10:51 -0800
committerRyan Davis <ryand-ruby@zenspider.com>2020-03-09 17:24:16 -0700
commit39e4c1b35ec7a8d9a703fa920e3f7b8698280784 (patch)
treeaa7bc3e6da67b78ed9ddd2a6fc428ce7121fbce5
parent7b8656bbf4b1dfff59866aa0199452a382841967 (diff)
downloadchef-39e4c1b35ec7a8d9a703fa920e3f7b8698280784.tar.gz
Extra initialization of civars in Resource.
This removes about 500 lines of warnings per run of a simple test file. About 33% reduction. Signed-off-by: Ryan Davis <zenspider@chef.io>
-rw-r--r--lib/chef/resource.rb9
1 files changed, 7 insertions, 2 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index ad2862c70b..5aa2969e0f 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -961,6 +961,8 @@ class Chef
@resource_name = nil
end
end
+
+ @resource_name = nil unless defined?(@resource_name)
@resource_name
end
@@ -973,7 +975,7 @@ class Chef
# @param flag [Boolean] value to set unified_mode to
# @return [Boolean] unified_mode value
def self.unified_mode(flag = nil)
- @unified_mode = Chef::Config[:resource_unified_mode_default] if @unified_mode.nil?
+ @unified_mode = Chef::Config[:resource_unified_mode_default] if !defined?(@unified_mode) || @unified_mode.nil?
@unified_mode = flag unless flag.nil?
!!@unified_mode
end
@@ -1018,7 +1020,7 @@ class Chef
self.allowed_actions |= @default_action
end
- if @default_action
+ if defined?(@default_action) && @default_action
@default_action
elsif superclass.respond_to?(:default_action)
superclass.default_action
@@ -1341,6 +1343,9 @@ class Chef
def self.provides(name, **options, &block)
name = name.to_sym
+ # quell warnings
+ @chef_version_for_provides = nil unless defined?(@chef_version_for_provides)
+
# deliberately do not go through the accessor here
@resource_name = name if resource_name.nil?