Class: Puppet::Pops::Model::TypeDefinition
- Inherits:
-
QRefDefinition
- Object
- PopsObject
- Positioned
- Expression
- Definition
- QRefDefinition
- Puppet::Pops::Model::TypeDefinition
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #body ⇒ Object readonly
- #parent ⇒ Object readonly
Attributes inherited from QRefDefinition
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, name, 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 {|@body| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, name, parent = nil, body = nil) ⇒ TypeDefinition
constructor
A new instance of TypeDefinition.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, name, parent = nil, body = nil) ⇒ TypeDefinition
Returns a new instance of TypeDefinition.
2363 2364 2365 2366 2367 2368 |
# File 'lib/puppet/pops/model/ast.rb', line 2363 def initialize(locator, offset, length, name, parent = nil, body = nil) super(locator, offset, length, name) @hash = @hash ^ parent.hash ^ body.hash @parent = parent @body = body end |
Instance Attribute Details
#body ⇒ Object (readonly)
2361 2362 2363 |
# File 'lib/puppet/pops/model/ast.rb', line 2361 def body @body end |
#parent ⇒ Object (readonly)
2360 2361 2362 |
# File 'lib/puppet/pops/model/ast.rb', line 2360 def parent @parent end |
Class Method Details
._pcore_type ⇒ Object
2316 2317 2318 2319 2320 2321 2322 2323 2324 2325 2326 2327 2328 2329 2330 2331 2332 |
# File 'lib/puppet/pops/model/ast.rb', line 2316 def self._pcore_type @_pcore_type ||= Types::PObjectType .new('Puppet::AST::TypeDefinition', { 'parent' => QRefDefinition._pcore_type, 'attributes' => { 'parent' => { 'type' => Types::POptionalType.new(Types::PStringType::DEFAULT), 'value' => nil }, 'body' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil } } }) end |
.create(locator, offset, length, name, parent = nil, body = nil) ⇒ Object
2348 2349 2350 2351 2352 2353 2354 2355 2356 2357 2358 |
# File 'lib/puppet/pops/model/ast.rb', line 2348 def self.create(locator, offset, length, name, 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::QRefDefinition[name]', attrs['name'].type, name) ta.assert_instance_of('Puppet::AST::TypeDefinition[parent]', attrs['parent'].type, parent) ta.assert_instance_of('Puppet::AST::TypeDefinition[body]', attrs['body'].type, body) new(locator, offset, length, name, parent, body) end |
.from_asserted_hash(init_hash) ⇒ Object
2338 2339 2340 2341 2342 2343 2344 2345 2346 |
# File 'lib/puppet/pops/model/ast.rb', line 2338 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['name'], init_hash['parent'], init_hash['body']) end |
.from_hash(init_hash) ⇒ Object
2334 2335 2336 |
# File 'lib/puppet/pops/model/ast.rb', line 2334 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::TypeDefinition initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
2381 2382 2383 2384 2385 2386 2387 2388 |
# File 'lib/puppet/pops/model/ast.rb', line 2381 def _pcore_all_contents(path, &block) path << self unless @body.nil? block.call(@body, path) @body._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@body| ... } ⇒ Object
2377 2378 2379 |
# File 'lib/puppet/pops/model/ast.rb', line 2377 def _pcore_contents yield(@body) unless @body.nil? end |
#_pcore_init_hash ⇒ Object
2370 2371 2372 2373 2374 2375 |
# File 'lib/puppet/pops/model/ast.rb', line 2370 def _pcore_init_hash result = super result['parent'] = @parent unless @parent == nil result['body'] = @body unless @body == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
2390 2391 2392 2393 2394 |
# File 'lib/puppet/pops/model/ast.rb', line 2390 def eql?(o) super && @parent.eql?(o.parent) && @body.eql?(o.body) end |