Class: Puppet::Pops::Model::ResourceDefaultsExpression

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

Instance Attribute Summary collapse

Attributes inherited from AbstractResource

#form

Attributes inherited from Positioned

#length, #locator, #offset

Attributes inherited from PopsObject

#hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from AbstractResource

#exported, #virtual

Methods inherited from Positioned

#file, #line, #pos

Methods inherited from PopsObject

#to_s

Methods included from Types::PuppetObject

#_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, form = "regular", type_ref = nil, operations = _pcore_type['operations'].value) ⇒ ResourceDefaultsExpression

Returns a new instance of ResourceDefaultsExpression


4428
4429
4430
4431
4432
4433
# File 'lib/puppet/pops/model/ast.rb', line 4428

def initialize(locator, offset, length, form = "regular", type_ref = nil, operations = _pcore_type['operations'].value)
  super(locator, offset, length, form)
  @hash = @hash ^ type_ref.hash ^ operations.hash
  @type_ref = type_ref
  @operations = operations
end

Instance Attribute Details

#operationsObject (readonly)


4426
4427
4428
# File 'lib/puppet/pops/model/ast.rb', line 4426

def operations
  @operations
end

#type_refObject (readonly)


4425
4426
4427
# File 'lib/puppet/pops/model/ast.rb', line 4425

def type_ref
  @type_ref
end

Class Method Details

._pcore_typeObject


4383
4384
4385
4386
4387
4388
4389
4390
4391
4392
4393
4394
4395
4396
4397
# File 'lib/puppet/pops/model/ast.rb', line 4383

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::ResourceDefaultsExpression', {
    'parent' => AbstractResource._pcore_type,
    'attributes' => {
      'type_ref' => {
        'type' => Types::POptionalType.new(Expression._pcore_type),
        'value' => nil
      },
      'operations' => {
        'type' => Types::PArrayType.new(AbstractAttributeOperation._pcore_type),
        'value' => []
      }
    }
  })
end

.create(locator, offset, length, form = "regular", type_ref = nil, operations = _pcore_type['operations'].value) ⇒ Object


4413
4414
4415
4416
4417
4418
4419
4420
4421
4422
4423
# File 'lib/puppet/pops/model/ast.rb', line 4413

def self.create(locator, offset, length, form = "regular", type_ref = nil, operations = _pcore_type['operations'].value)
  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)
  ta.assert_instance_of('Puppet::AST::ResourceDefaultsExpression[type_ref]', attrs['type_ref'].type, type_ref)
  ta.assert_instance_of('Puppet::AST::ResourceDefaultsExpression[operations]', attrs['operations'].type, operations)
  new(locator, offset, length, form, type_ref, operations)
end

.from_asserted_hash(init_hash) ⇒ Object


4403
4404
4405
4406
4407
4408
4409
4410
4411
# File 'lib/puppet/pops/model/ast.rb', line 4403

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

.from_hash(init_hash) ⇒ Object


4399
4400
4401
# File 'lib/puppet/pops/model/ast.rb', line 4399

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object


4447
4448
4449
4450
4451
4452
4453
4454
4455
4456
4457
4458
# File 'lib/puppet/pops/model/ast.rb', line 4447

def _pcore_all_contents(path, &block)
  path << self
  unless @type_ref.nil?
    block.call(@type_ref, path)
    @type_ref._pcore_all_contents(path, &block)
  end
  @operations.each do |value|
    block.call(value, path)
    value._pcore_all_contents(path, &block)
  end
  path.pop
end

#_pcore_contents {|@type_ref| ... } ⇒ Object

Yields:


4442
4443
4444
4445
# File 'lib/puppet/pops/model/ast.rb', line 4442

def _pcore_contents
  yield(@type_ref) unless @type_ref.nil?
  @operations.each { |value| yield(value) }
end

#_pcore_init_hashObject


4435
4436
4437
4438
4439
4440
# File 'lib/puppet/pops/model/ast.rb', line 4435

def _pcore_init_hash
  result = super
  result['type_ref'] = @type_ref unless @type_ref == nil
  result['operations'] = @operations unless _pcore_type['operations'].default_value?(@operations)
  result
end

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


4460
4461
4462
4463
4464
# File 'lib/puppet/pops/model/ast.rb', line 4460

def eql?(o)
  super &&
  @type_ref.eql?(o.type_ref) &&
  @operations.eql?(o.operations)
end