Sha256: 4966323ba8236de7e7bf19281558417261da5a19bc90f53af4ca1877d6e52eab

Contents?: true

Size: 719 Bytes

Versions: 18

Compression:

Stored size: 719 Bytes

Contents

require 'puppet/parser/ast'
require 'puppet/parser/ast/branch'

class Puppet::Parser::AST::ResourceReference < Puppet::Parser::AST::Branch
  attr_accessor :title, :type

  # Evaluate our object, but just return a simple array of the type
  # and name.
  def evaluate(scope)
    titles = Array(title.safeevaluate(scope))

    a_type, titles = scope.resolve_type_and_titles(type, titles)

    resources = titles.collect{ |a_title|
      Puppet::Resource.new(a_type, a_title)
    }

    return(resources.length == 1 ? resources.pop : resources)
  end

  def to_s
    if title.is_a?(Puppet::Parser::AST::ASTArray)
      "#{type.to_s.capitalize}#{title}"
    else
      "#{type.to_s.capitalize}[#{title}]"
    end
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
puppet-2.6.18 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.17 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.16 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.15 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.14 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.13 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.12 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.11 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.10 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.9 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.8 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.7 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.6 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.5 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.4 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.3 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.2 lib/puppet/parser/ast/resource_reference.rb
puppet-2.6.1 lib/puppet/parser/ast/resource_reference.rb