Class: Puppet::Pops::Model::NodeDefinition
- Inherits:
-
Definition
- Object
- PopsObject
- Positioned
- Expression
- Definition
- Puppet::Pops::Model::NodeDefinition
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #body ⇒ Object readonly
- #host_matches ⇒ Object readonly
- #parent ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, host_matches, parent = nil, body = nil) ⇒ Object
- .from_asserted_hash(init_hash) ⇒ Object
- .from_hash(init_hash) ⇒ Object
Instance Method Summary collapse
- #_pcore_all_contents(path, &block) ⇒ Object
- #_pcore_contents {|@parent| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, host_matches, parent = nil, body = nil) ⇒ NodeDefinition
constructor
A new instance of NodeDefinition.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, host_matches, parent = nil, body = nil) ⇒ NodeDefinition
Returns a new instance of NodeDefinition.
2396 2397 2398 2399 2400 2401 2402 |
# File 'lib/puppet/pops/model/ast.rb', line 2396 def initialize(locator, offset, length, host_matches, parent = nil, body = nil) super(locator, offset, length) @hash = @hash ^ parent.hash ^ host_matches.hash ^ body.hash @parent = parent @host_matches = host_matches @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
2394 2395 2396 |
# File 'lib/puppet/pops/model/ast.rb', line 2394 def body @body end |
#host_matches ⇒ Object (readonly)
2393 2394 2395 |
# File 'lib/puppet/pops/model/ast.rb', line 2393 def host_matches @host_matches end |
#parent ⇒ Object (readonly)
2392 2393 2394 |
# File 'lib/puppet/pops/model/ast.rb', line 2392 def parent @parent end |
Class Method Details
._pcore_type ⇒ Object
2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 2359 2360 2361 2362 2363 2364 |
# File 'lib/puppet/pops/model/ast.rb', line 2349 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::NodeDefinition', { 'parent' => Definition._pcore_type, 'attributes' => { 'parent' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil }, 'host_matches' => Types::PArrayType.new(Expression._pcore_type, Types::PCollectionType::NOT_EMPTY_SIZE), 'body' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil } } }) end |
.create(locator, offset, length, host_matches, parent = nil, body = nil) ⇒ Object
2380 2381 2382 2383 2384 2385 2386 2387 2388 2389 2390 |
# File 'lib/puppet/pops/model/ast.rb', line 2380 def self.create(locator, offset, length, host_matches, parent = nil, body = nil) ta = Types::TypeAsserter attrs = _pcore_type.attributes(true) ta.assert_instance_of('Puppet::AST::Positioned[locator]', attrs['locator'].type, locator) ta.assert_instance_of('Puppet::AST::Positioned[offset]', attrs['offset'].type, offset) ta.assert_instance_of('Puppet::AST::Positioned[length]', attrs['length'].type, length) ta.assert_instance_of('Puppet::AST::NodeDefinition[parent]', attrs['parent'].type, parent) ta.assert_instance_of('Puppet::AST::NodeDefinition[host_matches]', attrs['host_matches'].type, host_matches) ta.assert_instance_of('Puppet::AST::NodeDefinition[body]', attrs['body'].type, body) new(locator, offset, length, host_matches, parent, body) end |
.from_asserted_hash(init_hash) ⇒ Object
2370 2371 2372 2373 2374 2375 2376 2377 2378 |
# File 'lib/puppet/pops/model/ast.rb', line 2370 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['host_matches'], init_hash['parent'], init_hash['body']) end |
.from_hash(init_hash) ⇒ Object
2366 2367 2368 |
# File 'lib/puppet/pops/model/ast.rb', line 2366 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::NodeDefinition initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
2418 2419 2420 2421 2422 2423 2424 2425 2426 2427 2428 2429 2430 2431 2432 2433 |
# File 'lib/puppet/pops/model/ast.rb', line 2418 def _pcore_all_contents(path, &block) path << self unless @parent.nil? block.call(@parent, path) @parent._pcore_all_contents(path, &block) end @host_matches.each do |value| block.call(value, path) value._pcore_all_contents(path, &block) end unless @body.nil? block.call(@body, path) @body._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@parent| ... } ⇒ Object
2412 2413 2414 2415 2416 |
# File 'lib/puppet/pops/model/ast.rb', line 2412 def _pcore_contents yield(@parent) unless @parent.nil? @host_matches.each { |value| yield(value) } yield(@body) unless @body.nil? end |
#_pcore_init_hash ⇒ Object
2404 2405 2406 2407 2408 2409 2410 |
# File 'lib/puppet/pops/model/ast.rb', line 2404 def _pcore_init_hash result = super result['parent'] = @parent unless @parent == nil result['host_matches'] = @host_matches result['body'] = @body unless @body == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
2435 2436 2437 2438 2439 2440 |
# File 'lib/puppet/pops/model/ast.rb', line 2435 def eql?(o) super && @parent.eql?(o.parent) && @host_matches.eql?(o.host_matches) && @body.eql?(o.body) end |