Class: Puppet::Pops::Model::HostClassDefinition
- Inherits:
-
NamedDefinition
- Object
- PopsObject
- Positioned
- Expression
- Definition
- NamedDefinition
- Puppet::Pops::Model::HostClassDefinition
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #parent_class ⇒ Object readonly
Attributes inherited from NamedDefinition
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, name, parameters = _pcore_type['parameters'].value, body = nil, parent_class = 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, parameters = _pcore_type['parameters'].value, body = nil, parent_class = nil) ⇒ HostClassDefinition
constructor
A new instance of HostClassDefinition.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, name, parameters = _pcore_type['parameters'].value, body = nil, parent_class = nil) ⇒ HostClassDefinition
Returns a new instance of HostClassDefinition.
2563 2564 2565 2566 2567 |
# File 'lib/puppet/pops/model/ast.rb', line 2563 def initialize(locator, offset, length, name, parameters = _pcore_type['parameters'].value, body = nil, parent_class = nil) super(locator, offset, length, name, parameters, body) @hash = @hash ^ parent_class.hash @parent_class = parent_class end |
Instance Attribute Details
#parent_class ⇒ Object (readonly)
2561 2562 2563 |
# File 'lib/puppet/pops/model/ast.rb', line 2561 def parent_class @parent_class end |
Class Method Details
._pcore_type ⇒ Object
2521 2522 2523 2524 2525 2526 2527 2528 2529 2530 2531 |
# File 'lib/puppet/pops/model/ast.rb', line 2521 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::HostClassDefinition', { 'parent' => NamedDefinition._pcore_type, 'attributes' => { 'parent_class' => { 'type' => Types::POptionalType.new(Types::PStringType::DEFAULT), 'value' => nil } } }) end |
.create(locator, offset, length, name, parameters = _pcore_type['parameters'].value, body = nil, parent_class = nil) ⇒ Object
2548 2549 2550 2551 2552 2553 2554 2555 2556 2557 2558 2559 |
# File 'lib/puppet/pops/model/ast.rb', line 2548 def self.create(locator, offset, length, name, parameters = _pcore_type['parameters'].value, body = nil, parent_class = 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::NamedDefinition[name]', attrs['name'].type, name) ta.assert_instance_of('Puppet::AST::NamedDefinition[parameters]', attrs['parameters'].type, parameters) ta.assert_instance_of('Puppet::AST::NamedDefinition[body]', attrs['body'].type, body) ta.assert_instance_of('Puppet::AST::HostClassDefinition[parent_class]', attrs['parent_class'].type, parent_class) new(locator, offset, length, name, parameters, body, parent_class) end |
.from_asserted_hash(init_hash) ⇒ Object
2537 2538 2539 2540 2541 2542 2543 2544 2545 2546 |
# File 'lib/puppet/pops/model/ast.rb', line 2537 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['name'], init_hash.fetch('parameters') { _pcore_type['parameters'].value }, init_hash['body'], init_hash['parent_class']) end |
.from_hash(init_hash) ⇒ Object
2533 2534 2535 |
# File 'lib/puppet/pops/model/ast.rb', line 2533 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::HostClassDefinition initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
2580 2581 2582 2583 2584 2585 2586 2587 2588 2589 2590 2591 |
# File 'lib/puppet/pops/model/ast.rb', line 2580 def _pcore_all_contents(path, &block) path << self @parameters.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 {|@body| ... } ⇒ Object
2575 2576 2577 2578 |
# File 'lib/puppet/pops/model/ast.rb', line 2575 def _pcore_contents @parameters.each { |value| yield(value) } yield(@body) unless @body.nil? end |
#_pcore_init_hash ⇒ Object
2569 2570 2571 2572 2573 |
# File 'lib/puppet/pops/model/ast.rb', line 2569 def _pcore_init_hash result = super result['parent_class'] = @parent_class unless @parent_class == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
2593 2594 2595 2596 |
# File 'lib/puppet/pops/model/ast.rb', line 2593 def eql?(o) super && @parent_class.eql?(o.parent_class) end |