Method: Puppet::Type#autorelation
- Defined in:
- lib/puppet/type.rb
#autorelation(rel_type, rel_catalog = nil) ⇒ Object
TODO:
needs details - see the param rel_catalog, and type of this param
Adds dependencies to the catalog from added autorelations. See autorequire for how to add an auto-requirement.
2125 2126 2127 2128 2129 2130 2131 2132 2133 2134 2135 2136 2137 2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 2148 2149 2150 2151 2152 2153 2154 2155 2156 2157 2158 2159 2160 2161 2162 |
# File 'lib/puppet/type.rb', line 2125 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 |