summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordanielsdeleo <dan@opscode.com>2013-02-11 15:35:29 -0800
committerdanielsdeleo <dan@opscode.com>2013-02-11 15:35:29 -0800
commit3f12a8561bd10817db4fc2a4da26d071294a551e (patch)
tree6708d6f128e42f0b38b70838e1b2d3989f9cafb7
parent55e2af4669d325fd88b5862b12ade5cfb6917891 (diff)
downloadchef-3f12a8561bd10817db4fc2a4da26d071294a551e.tar.gz
allow lookup of resources without symbol creation
-rw-r--r--lib/chef/json_compat.rb4
-rw-r--r--lib/chef/resource.rb12
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/chef/json_compat.rb b/lib/chef/json_compat.rb
index 8ebd16470e..410dd51816 100644
--- a/lib/chef/json_compat.rb
+++ b/lib/chef/json_compat.rb
@@ -111,11 +111,11 @@ class Chef
when CHEF_SANDBOX
false
when CHEF_RESOURCE
- false
+ Chef::Resource
when CHEF_RESOURCECOLLECTION
Chef::ResourceCollection
when /^Chef::Resource/
- false
+ Chef::Resource.find_subclass_by_name(json_class)
else
raise ArgumentError, "Unsupported `json_class` type '#{json_class}'"
end
diff --git a/lib/chef/resource.rb b/lib/chef/resource.rb
index d18e8b0136..492b6a8f32 100644
--- a/lib/chef/resource.rb
+++ b/lib/chef/resource.rb
@@ -129,6 +129,18 @@ F
extend Chef::Mixin::ConvertToClassName
+ def self.resource_classes
+ @resource_classes ||= []
+ end
+
+ def self.inherited(subclass)
+ resource_classes << subclass
+ end
+
+ def self.find_subclass_by_name(class_name)
+ resource_classes.first {|c| c.name == class_name }
+ end
+
# Set or return the list of "state attributes" implemented by the Resource
# subclass. State attributes are attributes that describe the desired state
# of the system, such as file permissions or ownership. In general, state