# File lib/puppet/type.rb, line 1569
1569:   def autorequire(rel_catalog = nil)
1570:     rel_catalog ||= catalog
1571:     raise(Puppet::DevError, "You cannot add relationships without a catalog") unless rel_catalog
1572: 
1573:     reqs = []
1574:     self.class.eachautorequire { |type, block|
1575:       # Ignore any types we can't find, although that would be a bit odd.
1576:       next unless typeobj = Puppet::Type.type(type)
1577: 
1578:       # Retrieve the list of names from the block.
1579:       next unless list = self.instance_eval(&block)
1580:       list = [list] unless list.is_a?(Array)
1581: 
1582:       # Collect the current prereqs
1583:       list.each { |dep|
1584:         obj = nil
1585:         # Support them passing objects directly, to save some effort.
1586:         unless dep.is_a? Puppet::Type
1587:           # Skip autorequires that we aren't managing
1588:           unless dep = rel_catalog.resource(type, dep)
1589:             next
1590:           end
1591:         end
1592: 
1593:         reqs << Puppet::Relationship.new(dep, self)
1594:       }
1595:     }
1596: 
1597:     reqs
1598:   end