Class: Puppet::Pops::Model::ResourceOverrideExpression

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, resources, form = "regular", operations = _pcore_type['operations'].value) ⇒ ResourceOverrideExpression

Returns a new instance of ResourceOverrideExpression.



4511
4512
4513
4514
4515
4516
# File 'lib/puppet/pops/model/ast.rb', line 4511

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

Instance Attribute Details

#operationsObject (readonly)



4509
4510
4511
# File 'lib/puppet/pops/model/ast.rb', line 4509

def operations
  @operations
end

#resourcesObject (readonly)



4508
4509
4510
# File 'lib/puppet/pops/model/ast.rb', line 4508

def resources
  @resources
end

Class Method Details

._pcore_typeObject



4469
4470
4471
4472
4473
4474
4475
4476
4477
4478
4479
4480
# File 'lib/puppet/pops/model/ast.rb', line 4469

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

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



4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
# File 'lib/puppet/pops/model/ast.rb', line 4496

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

.from_asserted_hash(init_hash) ⇒ Object



4486
4487
4488
4489
4490
4491
4492
4493
4494
# File 'lib/puppet/pops/model/ast.rb', line 4486

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

.from_hash(init_hash) ⇒ Object



4482
4483
4484
# File 'lib/puppet/pops/model/ast.rb', line 4482

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
# File 'lib/puppet/pops/model/ast.rb', line 4530

def _pcore_all_contents(path, &block)
  path << self
  unless @resources.nil?
    block.call(@resources, path)
    @resources._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 {|@resources| ... } ⇒ Object

Yields:



4525
4526
4527
4528
# File 'lib/puppet/pops/model/ast.rb', line 4525

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

#_pcore_init_hashObject



4518
4519
4520
4521
4522
4523
# File 'lib/puppet/pops/model/ast.rb', line 4518

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

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

Returns:

  • (Boolean)


4543
4544
4545
4546
4547
# File 'lib/puppet/pops/model/ast.rb', line 4543

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