Class: Puppet::Pops::Model::QRefDefinition

Inherits:
Definition show all
Defined in:
lib/puppet/pops/model/ast.rb

Direct Known Subclasses

TypeAlias, TypeDefinition

Instance Attribute Summary collapse

Attributes inherited from Positioned

#length, #locator, #offset

Attributes inherited from PopsObject

#hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Positioned

#file, #line, #pos

Methods inherited from PopsObject

#_pcore_all_contents, #_pcore_contents, #to_s

Methods included from Types::PuppetObject

#_pcore_all_contents, #_pcore_contents, #_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, name) ⇒ QRefDefinition

Returns a new instance of QRefDefinition.



2137
2138
2139
2140
2141
# File 'lib/puppet/pops/model/ast.rb', line 2137

def initialize(locator, offset, length, name)
  super(locator, offset, length)
  @hash = @hash ^ name.hash
  @name = name
end

Instance Attribute Details

#nameObject (readonly)



2135
2136
2137
# File 'lib/puppet/pops/model/ast.rb', line 2135

def name
  @name
end

Class Method Details

._pcore_typeObject



2102
2103
2104
2105
2106
2107
2108
2109
2110
2111
# File 'lib/puppet/pops/model/ast.rb', line 2102

def self._pcore_type
  @_pcore_type ||=
    Types::PObjectType
      .new('Puppet::AST::QRefDefinition', {
             'parent' => Definition._pcore_type,
             'attributes' => {
               'name' => Types::PStringType::DEFAULT
             }
           })
end

.create(locator, offset, length, name) ⇒ Object



2125
2126
2127
2128
2129
2130
2131
2132
2133
# File 'lib/puppet/pops/model/ast.rb', line 2125

def self.create(locator, offset, length, name)
  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)
  new(locator, offset, length, name)
end

.from_asserted_hash(init_hash) ⇒ Object



2117
2118
2119
2120
2121
2122
2123
# File 'lib/puppet/pops/model/ast.rb', line 2117

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['name'])
end

.from_hash(init_hash) ⇒ Object



2113
2114
2115
# File 'lib/puppet/pops/model/ast.rb', line 2113

def self.from_hash(init_hash)
  from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::QRefDefinition initializer', _pcore_type.init_hash_type, init_hash))
end

Instance Method Details

#_pcore_init_hashObject



2143
2144
2145
2146
2147
# File 'lib/puppet/pops/model/ast.rb', line 2143

def _pcore_init_hash
  result = super
  result['name'] = @name
  result
end

#eql?(o) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


2149
2150
2151
2152
# File 'lib/puppet/pops/model/ast.rb', line 2149

def eql?(o)
  super &&
  @name.eql?(o.name)
end