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

Constructor Details

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

Returns a new instance of ResourceOverrideExpression.



4388
4389
4390
4391
4392
4393
# File 'lib/puppet/pops/model/ast.rb', line 4388

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)



4386
4387
4388
# File 'lib/puppet/pops/model/ast.rb', line 4386

def operations
  @operations
end

#resourcesObject (readonly)



4385
4386
4387
# File 'lib/puppet/pops/model/ast.rb', line 4385

def resources
  @resources
end

Class Method Details

._pcore_typeObject



4346
4347
4348
4349
4350
4351
4352
4353
4354
4355
4356
4357
# File 'lib/puppet/pops/model/ast.rb', line 4346

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



4373
4374
4375
4376
4377
4378
4379
4380
4381
4382
4383
# File 'lib/puppet/pops/model/ast.rb', line 4373

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



4363
4364
4365
4366
4367
4368
4369
4370
4371
# File 'lib/puppet/pops/model/ast.rb', line 4363

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



4359
4360
4361
# File 'lib/puppet/pops/model/ast.rb', line 4359

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



4407
4408
4409
4410
4411
4412
4413
4414
4415
4416
4417
4418
# File 'lib/puppet/pops/model/ast.rb', line 4407

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:



4402
4403
4404
4405
# File 'lib/puppet/pops/model/ast.rb', line 4402

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

#_pcore_init_hashObject



4395
4396
4397
4398
4399
4400
# File 'lib/puppet/pops/model/ast.rb', line 4395

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)


4420
4421
4422
4423
4424
# File 'lib/puppet/pops/model/ast.rb', line 4420

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