Class: Puppet::Parser::Relationship
- Defined in:
- lib/puppet/parser/relationship.rb
Constant Summary collapse
- PARAM_MAP =
{:relationship => :before, :subscription => :notify}
Instance Attribute Summary collapse
-
#source ⇒ Object
Returns the value of attribute source.
-
#target ⇒ Object
Returns the value of attribute target.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #evaluate(catalog) ⇒ Object
-
#initialize(source, target, type) ⇒ Relationship
constructor
A new instance of Relationship.
- #mk_relationship(source, target, catalog) ⇒ Object
- #param_name ⇒ Object
Constructor Details
#initialize(source, target, type) ⇒ Relationship
Returns a new instance of Relationship.
24 25 26 |
# File 'lib/puppet/parser/relationship.rb', line 24 def initialize(source, target, type) @source, @target, @type = source, target, type end |
Instance Attribute Details
#source ⇒ Object
Returns the value of attribute source.
2 3 4 |
# File 'lib/puppet/parser/relationship.rb', line 2 def source @source end |
#target ⇒ Object
Returns the value of attribute target.
2 3 4 |
# File 'lib/puppet/parser/relationship.rb', line 2 def target @target end |
#type ⇒ Object
Returns the value of attribute type.
2 3 4 |
# File 'lib/puppet/parser/relationship.rb', line 2 def type @type end |
Instance Method Details
#evaluate(catalog) ⇒ Object
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/puppet/parser/relationship.rb', line 6 def evaluate(catalog) if source.is_a?(Puppet::Parser::Collector) sources = source.collected.values else sources = [source] end if target.is_a?(Puppet::Parser::Collector) targets = target.collected.values else targets = [target] end sources.each do |s| targets.each do |t| mk_relationship(s, t, catalog) end end end |
#mk_relationship(source, target, catalog) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 |
# File 'lib/puppet/parser/relationship.rb', line 32 def mk_relationship(source, target, catalog) unless source_resource = catalog.resource(source.to_s) raise ArgumentError, "Could not find resource '#{source}' for relationship on '#{target}'" end unless target_resource = catalog.resource(target.to_s) raise ArgumentError, "Could not find resource '#{target}' for relationship from '#{source}'" end Puppet.debug "Adding relationship from #{source.to_s} to #{target.to_s} with '#{param_name}'" source_resource[param_name] ||= [] source_resource[param_name] << target.to_s end |