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.


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

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

Instance Attribute Details

#formObject (readonly)


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

def form
  @form
end

Class Method Details

._pcore_typeObject


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

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


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

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


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

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


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

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


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

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

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

Returns:

  • (Boolean)

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

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

#exportedObject


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

def exported
  @form == 'exported'
end

#virtualObject


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

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