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.
1118 1119 1120 1121 1122 |
# File 'lib/puppet/pops/model/ast.rb', line 1118 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)
1116 1117 1118 |
# File 'lib/puppet/pops/model/ast.rb', line 1116 def entries @entries end |
Class Method Details
._pcore_type ⇒ Object
1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 |
# File 'lib/puppet/pops/model/ast.rb', line 1082 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
1106 1107 1108 1109 1110 1111 1112 1113 1114 |
# File 'lib/puppet/pops/model/ast.rb', line 1106 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
1098 1099 1100 1101 1102 1103 1104 |
# File 'lib/puppet/pops/model/ast.rb', line 1098 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
1094 1095 1096 |
# File 'lib/puppet/pops/model/ast.rb', line 1094 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
1134 1135 1136 1137 1138 1139 1140 1141 |
# File 'lib/puppet/pops/model/ast.rb', line 1134 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
1130 1131 1132 |
# File 'lib/puppet/pops/model/ast.rb', line 1130 def _pcore_contents @entries.each { |value| yield(value) } end |
#_pcore_init_hash ⇒ Object
1124 1125 1126 1127 1128 |
# File 'lib/puppet/pops/model/ast.rb', line 1124 def _pcore_init_hash result = super result['entries'] = @entries unless _pcore_type['entries'].default_value?(@entries) result end |
#eql?(o) ⇒ Boolean Also known as: ==
1143 1144 1145 1146 |
# File 'lib/puppet/pops/model/ast.rb', line 1143 def eql?(o) super && @entries.eql?(o.entries) end |