Class: Puppet::Pops::Model::LiteralHash
- Inherits:
-
Expression
- Object
- PopsObject
- Positioned
- Expression
- Puppet::Pops::Model::LiteralHash
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #entries ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, entries = _pcore_type['entries'].value) ⇒ Object
- .from_asserted_hash(init_hash) ⇒ Object
- .from_hash(init_hash) ⇒ Object
Instance Method Summary collapse
- #_pcore_all_contents(path, &block) ⇒ Object
- #_pcore_contents ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, entries = _pcore_type['entries'].value) ⇒ LiteralHash
constructor
A new instance of LiteralHash.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, entries = _pcore_type['entries'].value) ⇒ LiteralHash
Returns a new instance of LiteralHash.
1141 1142 1143 1144 1145 |
# File 'lib/puppet/pops/model/ast.rb', line 1141 def initialize(locator, offset, length, entries = _pcore_type['entries'].value) super(locator, offset, length) @hash = @hash ^ entries.hash @entries = entries end |
Instance Attribute Details
#entries ⇒ Object (readonly)
1139 1140 1141 |
# File 'lib/puppet/pops/model/ast.rb', line 1139 def entries @entries end |
Class Method Details
._pcore_type ⇒ Object
1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 |
# File 'lib/puppet/pops/model/ast.rb', line 1103 def self._pcore_type @_pcore_type ||= Types::PObjectType .new('Puppet::AST::LiteralHash', { 'parent' => Expression._pcore_type, 'attributes' => { 'entries' => { 'type' => Types::PArrayType.new(KeyedEntry._pcore_type), 'value' => [] } } }) end |
.create(locator, offset, length, entries = _pcore_type['entries'].value) ⇒ Object
1129 1130 1131 1132 1133 1134 1135 1136 1137 |
# File 'lib/puppet/pops/model/ast.rb', line 1129 def self.create(locator, offset, length, entries = _pcore_type['entries'].value) 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::LiteralHash[entries]', attrs['entries'].type, entries) new(locator, offset, length, entries) end |
.from_asserted_hash(init_hash) ⇒ Object
1121 1122 1123 1124 1125 1126 1127 |
# File 'lib/puppet/pops/model/ast.rb', line 1121 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash.fetch('entries') { _pcore_type['entries'].value }) end |
.from_hash(init_hash) ⇒ Object
1117 1118 1119 |
# File 'lib/puppet/pops/model/ast.rb', line 1117 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::LiteralHash initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
1157 1158 1159 1160 1161 1162 1163 1164 |
# File 'lib/puppet/pops/model/ast.rb', line 1157 def _pcore_all_contents(path, &block) path << self @entries.each do |value| block.call(value, path) value._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents ⇒ Object
1153 1154 1155 |
# File 'lib/puppet/pops/model/ast.rb', line 1153 def _pcore_contents @entries.each { |value| yield(value) } end |
#_pcore_init_hash ⇒ Object
1147 1148 1149 1150 1151 |
# File 'lib/puppet/pops/model/ast.rb', line 1147 def _pcore_init_hash result = super result['entries'] = @entries unless _pcore_type['entries'].default_value?(@entries) result end |
#eql?(o) ⇒ Boolean Also known as: ==
1166 1167 1168 1169 |
# File 'lib/puppet/pops/model/ast.rb', line 1166 def eql?(o) super && @entries.eql?(o.entries) end |