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.



4083
4084
4085
4086
4087
# File 'lib/puppet/pops/model/ast.rb', line 4083

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

Instance Attribute Details

#formObject (readonly)



4073
4074
4075
# File 'lib/puppet/pops/model/ast.rb', line 4073

def form
  @form
end

Class Method Details

._pcore_typeObject



4029
4030
4031
4032
4033
4034
4035
4036
4037
4038
4039
4040
4041
4042
4043
4044
4045
4046
4047
4048
4049
# File 'lib/puppet/pops/model/ast.rb', line 4029

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



4063
4064
4065
4066
4067
4068
4069
4070
4071
# File 'lib/puppet/pops/model/ast.rb', line 4063

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



4055
4056
4057
4058
4059
4060
4061
# File 'lib/puppet/pops/model/ast.rb', line 4055

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



4051
4052
4053
# File 'lib/puppet/pops/model/ast.rb', line 4051

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



4089
4090
4091
4092
4093
# File 'lib/puppet/pops/model/ast.rb', line 4089

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

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

Returns:

  • (Boolean)


4095
4096
4097
4098
# File 'lib/puppet/pops/model/ast.rb', line 4095

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

#exportedObject



4079
4080
4081
# File 'lib/puppet/pops/model/ast.rb', line 4079

def exported
  @form == 'exported'
end

#virtualObject



4075
4076
4077
# File 'lib/puppet/pops/model/ast.rb', line 4075

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