summaryrefslogtreecommitdiffstats
path: root/lib/puppet/resource.rb
diff options
context:
space:
mode:
authorLuke Kanies <luke@puppetlabs.com>2010-07-07 23:34:10 -0700
committerMarkus Roberts <Markus@reality.com>2010-07-09 12:31:45 -0700
commit3c0059195fb2b1255f368d98021f4a99ecd121a6 (patch)
treeee22c31b02f14d267a24acce875f3f185fb16617 /lib/puppet/resource.rb
parentcea2e5b3fe03de8ef56a97af25ef8b6dd7eb3d7d (diff)
downloadpuppet-3c0059195fb2b1255f368d98021f4a99ecd121a6.tar.gz
puppet-3c0059195fb2b1255f368d98021f4a99ecd121a6.tar.xz
puppet-3c0059195fb2b1255f368d98021f4a99ecd121a6.zip
Fix for #4178 - generalize autoloading to include .rb
This mostly modifies autoloading to look for files ending in either 'pp' or 'rb' using Dir globing with {,.pp,.rb} or .{pp,rb} as appropriate. It could easily be extended to add support for other formats (e.g. xml) by adding them to the globs (though, if this were to be done often, having a centralized list of supported extensions would be a good (and easy) refactor). Signed-off-by: Luke Kanies <luke@puppetlabs.com>
Diffstat (limited to 'lib/puppet/resource.rb')
-rw-r--r--lib/puppet/resource.rb15
1 files changed, 5 insertions, 10 deletions
diff --git a/lib/puppet/resource.rb b/lib/puppet/resource.rb
index 393211e09..3b96e7e99 100644
--- a/lib/puppet/resource.rb
+++ b/lib/puppet/resource.rb
@@ -351,7 +351,8 @@ class Puppet::Resource
end
def find_resource_type(type)
- find_builtin_resource_type(type) || find_defined_resource_type(type)
+ # It still works fine without the type == 'class' short-cut, but it is a lot slower.
+ find_builtin_resource_type(type) || find_defined_resource_type(type) unless type.to_s.downcase == 'class'
end
def find_builtin_resource_type(type)
@@ -432,18 +433,12 @@ class Puppet::Resource
end
def resolve_type
- type = munge_type_name(@unresolved_type)
-
- case type
+ case type = munge_type_name(@unresolved_type)
when "Class", "Node";
- return type
+ type
else
# Otherwise, some kind of builtin or defined resource type
- return munge_type_name(if r = find_resource_type(type)
- r.name
- else
- type
- end)
+ munge_type_name( (r = find_resource_type(type)) ? r.name : type)
end
end