Class: Puppet::Parser::AST::Resource
- Inherits:
-
ResourceReference
- Object
- Puppet::Parser::AST
- Branch
- ResourceReference
- Puppet::Parser::AST::Resource
- Defined in:
- lib/puppet/parser/ast/resource.rb
Direct Known Subclasses
Constant Summary
Constants inherited from Puppet::Parser::AST
Instance Attribute Summary collapse
-
#exported ⇒ Object
Returns the value of attribute exported.
-
#parameters ⇒ Object
Returns the value of attribute parameters.
-
#title ⇒ Object
Returns the value of attribute title.
-
#type ⇒ Object
Returns the value of attribute type.
-
#virtual ⇒ Object
Returns the value of attribute virtual.
Attributes inherited from Branch
Attributes inherited from Puppet::Parser::AST
Attributes included from Util::Docs
Attributes included from FileCollection::Lookup
Instance Method Summary collapse
-
#evaluate(scope) ⇒ Object
Does not actually return an object; instead sets an object in the current scope.
Methods inherited from ResourceReference
Methods inherited from Branch
Methods inherited from Puppet::Parser::AST
associates_doc, #evaluate_match, #initialize, #inspect, #parsefail, #parsewrap, #safeevaluate, settor?, #use_docs
Methods included from Util::Docs
#desc, #dochook, #doctable, #nodoc?, #pad, scrub
Methods included from Util::MethodHelper
#requiredopts, #set_options, #symbolize_options
Methods included from Util::Errors
#adderrorcontext, #devfail, #error_context, #exceptwrap, #fail
Methods included from FileCollection::Lookup
#file, #file=, #file_collection
Constructor Details
This class inherits a constructor from Puppet::Parser::AST::Branch
Instance Attribute Details
#exported ⇒ Object
Returns the value of attribute exported.
10 11 12 |
# File 'lib/puppet/parser/ast/resource.rb', line 10 def exported @exported end |
#parameters ⇒ Object
Returns the value of attribute parameters.
11 12 13 |
# File 'lib/puppet/parser/ast/resource.rb', line 11 def parameters @parameters end |
#title ⇒ Object
Returns the value of attribute title.
10 11 12 |
# File 'lib/puppet/parser/ast/resource.rb', line 10 def title @title end |
#type ⇒ Object
Returns the value of attribute type.
10 11 12 |
# File 'lib/puppet/parser/ast/resource.rb', line 10 def type @type end |
#virtual ⇒ Object
Returns the value of attribute virtual.
10 11 12 |
# File 'lib/puppet/parser/ast/resource.rb', line 10 def virtual @virtual end |
Instance Method Details
#evaluate(scope) ⇒ Object
Does not actually return an object; instead sets an object in the current scope.
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/puppet/parser/ast/resource.rb', line 15 def evaluate(scope) # Evaluate all of the specified params. paramobjects = parameters.collect { |param| param.safeevaluate(scope) } resource_titles = @title.safeevaluate(scope) # it's easier to always use an array, even for only one name resource_titles = [resource_titles] unless resource_titles.is_a?(Array) # We want virtual to be true if exported is true. We can't # just set :virtual => self.virtual in the initialization, # because sometimes the :virtual attribute is set *after* # :exported, in which case it clobbers :exported if :exported # is true. Argh, this was a very tough one to track down. virt = self.virtual || self.exported # This is where our implicit iteration takes place; if someone # passed an array as the name, then we act just like the called us # many times. fully_qualified_type, resource_titles = scope.resolve_type_and_titles(type, resource_titles) resource_titles.flatten.collect { |resource_title| exceptwrap :type => Puppet::ParseError do resource = Puppet::Parser::Resource.new( fully_qualified_type, resource_title, :parameters => paramobjects, :file => self.file, :line => self.line, :exported => self.exported, :virtual => virt, :source => scope.source, :scope => scope, :strict => true ) if resource.resource_type.is_a? Puppet::Resource::Type resource.resource_type.instantiate_resource(scope, resource) end scope.compiler.add_resource(scope, resource) scope.compiler.evaluate_classes([resource_title],scope,false) if fully_qualified_type == 'class' resource end }.reject { |resource| resource.nil? } end |