# class Puppet::Parser::AST::Relationship

### Constants

RELATIONSHIP_TYPES

### Attributes

arrow[RW]
left[RW]
right[RW]
type[RW]

### Public Class Methods

new(left, right, arrow, args = {}) click to toggle source
Calls superclass method Puppet::Parser::AST::Branch.new

    # File lib/puppet/parser/ast/relationship.rb, line 22
    def initialize(left, right, arrow, args = {})
      super(args)
      unless RELATIONSHIP_TYPES.include?(arrow)
        raise ArgumentError, "Invalid relationship type #{arrow.inspect}; valid types are #{RELATIONSHIP_TYPES.collect { |r| r.to_s }.join(", ")}"
      end
      @left, @right, @arrow = left, right, arrow
    end

### Public Instance Methods

evaluate(scope) click to toggle source

Evaluate our object, but just return a simple array of the type and name.

    # File lib/puppet/parser/ast/relationship.rb, line 12
    def evaluate(scope)
      real_left = left.safeevaluate(scope)
      real_right = right.safeevaluate(scope)

      source, target = sides2edge(real_left, real_right)
      scope.compiler.add_relationship Puppet::Parser::Relationship.new(source, target, type)

      real_right
    end

sides2edge(left, right) click to toggle source

    # File lib/puppet/parser/ast/relationship.rb, line 34
    def sides2edge(left, right)
      out_edge? ? [left, right] : [right, left]
    end