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 11:56:12 -0700
commit80c992553269793e214fb2f72180c27630206e9d (patch)
treeef8dd0d42ea54eef33a6f531b3fd603e9c5f6b50
parent399c78c5391ded6ab0d18ba40ce16ab684bd8805 (diff)
downloadchef-80c992553269793e214fb2f72180c27630206e9d.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?