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.



3995
3996
3997
3998
3999
# File 'lib/puppet/pops/model/ast.rb', line 3995

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

Instance Attribute Details

#formObject (readonly)



3985
3986
3987
# File 'lib/puppet/pops/model/ast.rb', line 3985

def form
  @form
end

Class Method Details

._pcore_typeObject



3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
3960
3961
# File 'lib/puppet/pops/model/ast.rb', line 3943

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



3975
3976
3977
3978
3979
3980
3981
3982
3983
# File 'lib/puppet/pops/model/ast.rb', line 3975

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



3967
3968
3969
3970
3971
3972
3973
# File 'lib/puppet/pops/model/ast.rb', line 3967

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



3963
3964
3965
# File 'lib/puppet/pops/model/ast.rb', line 3963

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



4001
4002
4003
4004
4005
# File 'lib/puppet/pops/model/ast.rb', line 4001

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

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

Returns:

  • (Boolean)


4007
4008
4009
4010
# File 'lib/puppet/pops/model/ast.rb', line 4007

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

#exportedObject



3991
3992
3993
# File 'lib/puppet/pops/model/ast.rb', line 3991

def exported
  @form == 'exported'
end

#virtualObject



3987
3988
3989
# File 'lib/puppet/pops/model/ast.rb', line 3987

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