Class: Puppet::Pops::Model::AbstractResource

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

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, form = "regular") ⇒ AbstractResource

Returns a new instance of AbstractResource.



4185
4186
4187
4188
4189
# File 'lib/puppet/pops/model/ast.rb', line 4185

def initialize(locator, offset, length, form = "regular")
  super(locator, offset, length)
  @hash = @hash ^ form.hash
  @form = form
end

Instance Attribute Details

#formObject (readonly)



4175
4176
4177
# File 'lib/puppet/pops/model/ast.rb', line 4175

def form
  @form
end

Class Method Details

._pcore_typeObject



4133
4134
4135
4136
4137
4138
4139
4140
4141
4142
4143
4144
4145
4146
4147
4148
4149
4150
4151
# File 'lib/puppet/pops/model/ast.rb', line 4133

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::AbstractResource', {
    'parent' => Expression._pcore_type,
    'attributes' => {
      'form' => {
        'type' => Types::PEnumType.new(['exported', 'regular', 'virtual']),
        'value' => 'regular'
      },
      'virtual' => {
        'type' => Types::PBooleanType::DEFAULT,
        'kind' => 'derived'
      },
      'exported' => {
        'type' => Types::PBooleanType::DEFAULT,
        'kind' => 'derived'
      }
    }
  })
end

.create(locator, offset, length, form = "regular") ⇒ Object



4165
4166
4167
4168
4169
4170
4171
4172
4173
# File 'lib/puppet/pops/model/ast.rb', line 4165

def self.create(locator, offset, length, form = "regular")
  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::AbstractResource[form]', attrs['form'].type, form)
  new(locator, offset, length, form)
end

.from_asserted_hash(init_hash) ⇒ Object



4157
4158
4159
4160
4161
4162
4163
# File 'lib/puppet/pops/model/ast.rb', line 4157

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash.fetch('form') { "regular" })
end

.from_hash(init_hash) ⇒ Object



4153
4154
4155
# File 'lib/puppet/pops/model/ast.rb', line 4153

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

Instance Method Details

#_pcore_init_hashObject



4191
4192
4193
4194
4195
# File 'lib/puppet/pops/model/ast.rb', line 4191

def _pcore_init_hash
  result = super
  result['form'] = @form unless @form == "regular"
  result
end

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

Returns:

  • (Boolean)


4197
4198
4199
4200
# File 'lib/puppet/pops/model/ast.rb', line 4197

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

#exportedObject



4181
4182
4183
# File 'lib/puppet/pops/model/ast.rb', line 4181

def exported
  @form == 'exported'
end

#virtualObject



4177
4178
4179
# File 'lib/puppet/pops/model/ast.rb', line 4177

def virtual
  @form == 'virtual' || @form == 'exported'
end