diff options
Diffstat (limited to 'lib/puppet/parser/relationship.rb')
-rw-r--r-- | lib/puppet/parser/relationship.rb | 68 |
1 files changed, 34 insertions, 34 deletions
diff --git a/lib/puppet/parser/relationship.rb b/lib/puppet/parser/relationship.rb index 1d1bad76c..6190df52c 100644 --- a/lib/puppet/parser/relationship.rb +++ b/lib/puppet/parser/relationship.rb @@ -1,43 +1,43 @@ class Puppet::Parser::Relationship - attr_accessor :source, :target, :type + attr_accessor :source, :target, :type - PARAM_MAP = {:relationship => :before, :subscription => :notify} + PARAM_MAP = {:relationship => :before, :subscription => :notify} - 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 + def evaluate(catalog) + if source.is_a?(Puppet::Parser::Collector) + sources = source.collected.values + else + sources = [source] end - - def initialize(source, target, type) - @source, @target, @type = source, target, type + if target.is_a?(Puppet::Parser::Collector) + targets = target.collected.values + else + targets = [target] end - - def param_name - PARAM_MAP[type] || raise(ArgumentError, "Invalid relationship type #{type}") + sources.each do |s| + targets.each do |t| + mk_relationship(s, t, catalog) + end end + end + + def initialize(source, target, type) + @source, @target, @type = source, target, type + end - 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 + def param_name + PARAM_MAP[type] || raise(ArgumentError, "Invalid relationship type #{type}") + end + + 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 end |