summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/parser/scope.rb15
-rw-r--r--lib/puppet/resource/type_collection.rb27
2 files changed, 20 insertions, 22 deletions
diff --git a/lib/puppet/parser/scope.rb b/lib/puppet/parser/scope.rb
index b79b344e3..bb8725096 100644
--- a/lib/puppet/parser/scope.rb
+++ b/lib/puppet/parser/scope.rb
@@ -22,6 +22,7 @@ class Puppet::Parser::Scope
attr_accessor :base, :keyword, :nodescope
attr_accessor :top, :translated, :compiler
attr_accessor :parent
+ attr_reader :namespaces
# A demeterific shortcut to the catalog.
def catalog
@@ -86,21 +87,11 @@ class Puppet::Parser::Scope
end
def find_hostclass(name)
- @namespaces.each do |namespace|
- if r = known_resource_types.find_hostclass(namespace, name)
- return r
- end
- end
- return nil
+ known_resource_types.find_hostclass(namespaces, name)
end
def find_definition(name)
- @namespaces.each do |namespace|
- if r = known_resource_types.find_definition(namespace, name)
- return r
- end
- end
- return nil
+ known_resource_types.find_definition(namespaces, name)
end
def findresource(string, name = nil)
diff --git a/lib/puppet/resource/type_collection.rb b/lib/puppet/resource/type_collection.rb
index 7ca95b1b8..a0bd2ddf5 100644
--- a/lib/puppet/resource/type_collection.rb
+++ b/lib/puppet/resource/type_collection.rb
@@ -75,24 +75,31 @@ class Puppet::Resource::TypeCollection
@definitions[munge_name(name)]
end
- def find(namespace, name, type)
+ def find(namespaces, name, type)
if r = find_fully_qualified(name, type)
return r
end
- ary = namespace.split("::")
+ namespaces = Array(namespaces)
- while ary.length > 0
- tmp_namespace = ary.join("::")
- if r = find_partially_qualified(tmp_namespace, name, type)
- return r
+ namespaces.each do |namespace|
+ ary = namespace.split("::")
+
+ while ary.length > 0
+ tmp_namespace = ary.join("::")
+ if r = find_partially_qualified(tmp_namespace, name, type)
+ return r
+ end
+
+ # Delete the second to last object, which reduces our namespace by one.
+ ary.pop
end
- # Delete the second to last object, which reduces our namespace by one.
- ary.pop
+ if result = send(type, name)
+ return result
+ end
end
-
- send(type, name)
+ nil
end
def find_node(name)