summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRyan Davis <ryand-ruby@zenspider.com>2020-03-06 17:10:51 -0800
committerTim Smith <tsmith84@gmail.com>2020-03-16 15:50:05 -0700
commit55faea97db218596e654c891cb12835462e3caec (patch)
tree6bcbb45ecc2bf21462a7678754996c2ca5bac580
parentaa7a29cdf0947bc7ea5b8671e151e60902bd500a (diff)
downloadchef-55faea97db218596e654c891cb12835462e3caec.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 6c7214fdd9..38921334ba 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -965,6 +965,8 @@ class Chef
@resource_name = nil
end
end
+
+ @resource_name = nil unless defined?(@resource_name)
@resource_name
end
@@ -990,7 +992,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
@@ -1035,7 +1037,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
@@ -1366,6 +1368,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)
+
# `provides :resource_name, os: 'linux'`) needs to remove the old
# canonical DSL before adding the new one.
if @resource_name && name == @resource_name