Sha256: 672e93e5f994786595c94c508822afe1660bbfaf1c7194eb25490c5aaaaf218f

Contents?: true

Size: 727 Bytes

Versions: 151

Compression:

Stored size: 727 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)).flatten

    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

151 entries across 151 versions & 5 rubygems

Version Path
puppet-retrospec-0.12.2 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.7 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.7-x86-mingw32 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.7-x64-mingw32 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.6 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.6-x86-mingw32 lib/puppet/parser/ast/resource_reference.rb
puppet-retrospec-0.12.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.6-x64-mingw32 lib/puppet/parser/ast/resource_reference.rb
puppet-retrospec-0.12.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.5 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.5-x86-mingw32 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.5-x64-mingw32 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.4 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.4-x86-mingw32 lib/puppet/parser/ast/resource_reference.rb
puppet-3.8.4-x64-mingw32 lib/puppet/parser/ast/resource_reference.rb
puppet-retrospec-0.11.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/resource_reference.rb
puppet-retrospec-0.10.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/resource_reference.rb
puppet-retrospec-0.9.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/resource_reference.rb
puppet-retrospec-0.9.0 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/resource_reference.rb
puppet-retrospec-0.8.1 vendor/gems/puppet-3.7.3/lib/puppet/parser/ast/resource_reference.rb