def autorelation(rel_type, rel_catalog = nil)
    rel_catalog ||= catalog
    raise Puppet::DevError, _("You cannot add relationships without a catalog") unless rel_catalog

    reqs = []

    auto_rel = "eachauto#{rel_type}".to_sym

    self.class.send(auto_rel) { |type, block|
      # Ignore any types we can't find, although that would be a bit odd.
      next unless Puppet::Type.type(type)

      # Retrieve the list of names from the block.
      next unless list = self.instance_eval(&block)
      list = [list] unless list.is_a?(Array)

      # Collect the current prereqs
      list.each { |dep|
        next if dep.nil?

        # Support them passing objects directly, to save some effort.
        unless dep.is_a?(Puppet::Type)
          # Skip autorelation that we aren't managing
          unless dep = rel_catalog.resource(type, dep)
            next
          end
        end

        if [:require, :subscribe].include?(rel_type)
          reqs << Puppet::Relationship.new(dep, self)
        else
          reqs << Puppet::Relationship.new(self, dep)
        end
      }
    }

    reqs
  end
def autorelation(rel_type, rel_catalog = nil)
    rel_catalog ||= catalog
    raise Puppet::DevError, _("You cannot add relationships without a catalog") unless rel_catalog

    reqs = []

    auto_rel = "eachauto#{rel_type}".to_sym

    self.class.send(auto_rel) { |type, block|
      # Ignore any types we can't find, although that would be a bit odd.
      next unless Puppet::Type.type(type)

      # Retrieve the list of names from the block.
      next unless list = self.instance_eval(&block)
      list = [list] unless list.is_a?(Array)

      # Collect the current prereqs
      list.each { |dep|
        next if dep.nil?

        # Support them passing objects directly, to save some effort.
        unless dep.is_a?(Puppet::Type)
          # Skip autorelation that we aren't managing
          unless dep = rel_catalog.resource(type, dep)
            next
          end
        end

        if [:require, :subscribe].include?(rel_type)
          reqs << Puppet::Relationship.new(dep, self)
        else
          reqs << Puppet::Relationship.new(self, dep)
        end
      }
    }

    reqs
  end
Adds dependencies to the catalog from added autorelations.
 See {autorequire} for how to add an auto-requirement.
 @todo needs details - see the param rel_catalog, and type of this param
 @param rel_catalog [Puppet::Resource::Catalog, nil] the catalog to
   add dependencies to. Defaults to the current catalog (set when the
   type instance was added to a catalog)
 @raise [Puppet::DevError] if there is no catalog