Class: Puppet::Pops::Model::TypeMapping
- Inherits:
-
Definition
- Object
- PopsObject
- Positioned
- Expression
- Definition
- Puppet::Pops::Model::TypeMapping
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #mapping_expr ⇒ Object readonly
- #type_expr ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, type_expr = nil, mapping_expr = 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 {|@type_expr| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, type_expr = nil, mapping_expr = nil) ⇒ TypeMapping
constructor
A new instance of TypeMapping.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, type_expr = nil, mapping_expr = nil) ⇒ TypeMapping
Returns a new instance of TypeMapping.
2227 2228 2229 2230 2231 2232 |
# File 'lib/puppet/pops/model/ast.rb', line 2227 def initialize(locator, offset, length, type_expr = nil, mapping_expr = nil) super(locator, offset, length) @hash = @hash ^ type_expr.hash ^ mapping_expr.hash @type_expr = type_expr @mapping_expr = mapping_expr end |
Instance Attribute Details
#mapping_expr ⇒ Object (readonly)
2225 2226 2227 |
# File 'lib/puppet/pops/model/ast.rb', line 2225 def mapping_expr @mapping_expr end |
#type_expr ⇒ Object (readonly)
2224 2225 2226 |
# File 'lib/puppet/pops/model/ast.rb', line 2224 def type_expr @type_expr end |
Class Method Details
._pcore_type ⇒ Object
2184 2185 2186 2187 2188 2189 2190 2191 2192 2193 2194 2195 2196 2197 2198 |
# File 'lib/puppet/pops/model/ast.rb', line 2184 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::TypeMapping', { 'parent' => Definition._pcore_type, 'attributes' => { 'type_expr' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil }, 'mapping_expr' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil } } }) end |
.create(locator, offset, length, type_expr = nil, mapping_expr = nil) ⇒ Object
2213 2214 2215 2216 2217 2218 2219 2220 2221 2222 |
# File 'lib/puppet/pops/model/ast.rb', line 2213 def self.create(locator, offset, length, type_expr = nil, mapping_expr = 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::TypeMapping[type_expr]', attrs['type_expr'].type, type_expr) ta.assert_instance_of('Puppet::AST::TypeMapping[mapping_expr]', attrs['mapping_expr'].type, mapping_expr) new(locator, offset, length, type_expr, mapping_expr) end |
.from_asserted_hash(init_hash) ⇒ Object
2204 2205 2206 2207 2208 2209 2210 2211 |
# File 'lib/puppet/pops/model/ast.rb', line 2204 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['type_expr'], init_hash['mapping_expr']) end |
.from_hash(init_hash) ⇒ Object
2200 2201 2202 |
# File 'lib/puppet/pops/model/ast.rb', line 2200 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::TypeMapping initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
2246 2247 2248 2249 2250 2251 2252 2253 2254 2255 2256 2257 |
# File 'lib/puppet/pops/model/ast.rb', line 2246 def _pcore_all_contents(path, &block) path << self unless @type_expr.nil? block.call(@type_expr, path) @type_expr._pcore_all_contents(path, &block) end unless @mapping_expr.nil? block.call(@mapping_expr, path) @mapping_expr._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@type_expr| ... } ⇒ Object
2241 2242 2243 2244 |
# File 'lib/puppet/pops/model/ast.rb', line 2241 def _pcore_contents yield(@type_expr) unless @type_expr.nil? yield(@mapping_expr) unless @mapping_expr.nil? end |
#_pcore_init_hash ⇒ Object
2234 2235 2236 2237 2238 2239 |
# File 'lib/puppet/pops/model/ast.rb', line 2234 def _pcore_init_hash result = super result['type_expr'] = @type_expr unless @type_expr == nil result['mapping_expr'] = @mapping_expr unless @mapping_expr == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
2259 2260 2261 2262 2263 |
# File 'lib/puppet/pops/model/ast.rb', line 2259 def eql?(o) super && @type_expr.eql?(o.type_expr) && @mapping_expr.eql?(o.mapping_expr) end |