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.
2745 2746 2747 2748 2749 |
# File 'lib/puppet/pops/model/ast.rb', line 2745 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)
2743 2744 2745 |
# File 'lib/puppet/pops/model/ast.rb', line 2743 def parent_class @parent_class end |
Class Method Details
._pcore_type ⇒ Object
2703 2704 2705 2706 2707 2708 2709 2710 2711 2712 2713 |
# File 'lib/puppet/pops/model/ast.rb', line 2703 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
2730 2731 2732 2733 2734 2735 2736 2737 2738 2739 2740 2741 |
# File 'lib/puppet/pops/model/ast.rb', line 2730 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
2719 2720 2721 2722 2723 2724 2725 2726 2727 2728 |
# File 'lib/puppet/pops/model/ast.rb', line 2719 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
2715 2716 2717 |
# File 'lib/puppet/pops/model/ast.rb', line 2715 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
2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 |
# File 'lib/puppet/pops/model/ast.rb', line 2762 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
2757 2758 2759 2760 |
# File 'lib/puppet/pops/model/ast.rb', line 2757 def _pcore_contents @parameters.each { |value| yield(value) } yield(@body) unless @body.nil? end |
#_pcore_init_hash ⇒ Object
2751 2752 2753 2754 2755 |
# File 'lib/puppet/pops/model/ast.rb', line 2751 def _pcore_init_hash result = super result['parent_class'] = @parent_class unless @parent_class == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
2775 2776 2777 2778 |
# File 'lib/puppet/pops/model/ast.rb', line 2775 def eql?(o) super && @parent_class.eql?(o.parent_class) end |