Method: Puppet::Resource::Ral#search

Defined in:
lib/puppet/indirector/resource/ral.rb

#search(request) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/puppet/indirector/resource/ral.rb', line 20

def search( request )
  conditions = request.options.dup
  conditions[:name] = resource_name(request) if resource_name(request)

  type(request).instances.map do |res|
    res.to_resource
  end.find_all do |res|
    conditions.all? do |property, value|
      # even though `res` is an instance of Puppet::Resource, calling
      # `res[:name]` on it returns nil, and for some reason it is necessary
      # to invoke the Puppet::Resource#copy_as_resource copy constructor...
      res.copy_as_resource[property].to_s == value.to_s
    end
  end.sort_by(&:title)
end