summaryrefslogtreecommitdiff
path: root/lib/chef/resource.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/resource.rb')
-rw-r--r--lib/chef/resource.rb16
1 files changed, 15 insertions, 1 deletions
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index 729632a69c..eb8d7bbf05 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -129,10 +129,24 @@ F
extend Chef::Mixin::ConvertToClassName
+
+ if Module.method(:const_defined?).arity == 1
+ def self.strict_const_defined?(const)
+ const_defined?(const)
+ end
+ else
+ def self.strict_const_defined?(const)
+ const_defined?(const, false)
+ end
+ end
+
# Track all subclasses of Resource. This is used so names can be looked up
# when attempting to deserialize from JSON. (See: json_compat)
def self.resource_classes
- @resource_classes ||= []
+ # Using a class variable here ensures we have one variable to track
+ # subclasses shared by the entire class hierarchy; without this, each
+ # subclass would have its own list of subclasses.
+ @@resource_classes ||= []
end
# Callback when subclass is defined. Adds subclass to list of subclasses.