Class: Puppet::Pops::Model::TypeAlias
- Inherits:
-
QRefDefinition
- Object
- PopsObject
- Positioned
- Expression
- Definition
- QRefDefinition
- Puppet::Pops::Model::TypeAlias
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #type_expr ⇒ Object readonly
Attributes inherited from QRefDefinition
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, name, type_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, name, type_expr = nil) ⇒ TypeAlias
constructor
A new instance of TypeAlias.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, name, type_expr = nil) ⇒ TypeAlias
Returns a new instance of TypeAlias.
2151 2152 2153 2154 2155 |
# File 'lib/puppet/pops/model/ast.rb', line 2151 def initialize(locator, offset, length, name, type_expr = nil) super(locator, offset, length, name) @hash = @hash ^ type_expr.hash @type_expr = type_expr end |
Instance Attribute Details
#type_expr ⇒ Object (readonly)
2149 2150 2151 |
# File 'lib/puppet/pops/model/ast.rb', line 2149 def type_expr @type_expr end |
Class Method Details
._pcore_type ⇒ Object
2113 2114 2115 2116 2117 2118 2119 2120 2121 2122 2123 |
# File 'lib/puppet/pops/model/ast.rb', line 2113 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::TypeAlias', { 'parent' => QRefDefinition._pcore_type, 'attributes' => { 'type_expr' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil } } }) end |
.create(locator, offset, length, name, type_expr = nil) ⇒ Object
2138 2139 2140 2141 2142 2143 2144 2145 2146 2147 |
# File 'lib/puppet/pops/model/ast.rb', line 2138 def self.create(locator, offset, length, name, type_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::QRefDefinition[name]', attrs['name'].type, name) ta.assert_instance_of('Puppet::AST::TypeAlias[type_expr]', attrs['type_expr'].type, type_expr) new(locator, offset, length, name, type_expr) end |
.from_asserted_hash(init_hash) ⇒ Object
2129 2130 2131 2132 2133 2134 2135 2136 |
# File 'lib/puppet/pops/model/ast.rb', line 2129 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['name'], init_hash['type_expr']) end |
.from_hash(init_hash) ⇒ Object
2125 2126 2127 |
# File 'lib/puppet/pops/model/ast.rb', line 2125 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::TypeAlias initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
2167 2168 2169 2170 2171 2172 2173 2174 |
# File 'lib/puppet/pops/model/ast.rb', line 2167 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 path.pop end |
#_pcore_contents {|@type_expr| ... } ⇒ Object
2163 2164 2165 |
# File 'lib/puppet/pops/model/ast.rb', line 2163 def _pcore_contents yield(@type_expr) unless @type_expr.nil? end |
#_pcore_init_hash ⇒ Object
2157 2158 2159 2160 2161 |
# File 'lib/puppet/pops/model/ast.rb', line 2157 def _pcore_init_hash result = super result['type_expr'] = @type_expr unless @type_expr == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
2176 2177 2178 2179 |
# File 'lib/puppet/pops/model/ast.rb', line 2176 def eql?(o) super && @type_expr.eql?(o.type_expr) end |