Class: Puppet::Pops::Model::CapabilityMapping

Inherits:
Definition 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

#to_s

Methods included from Types::PuppetObject

#_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, kind, capability, component, mappings = _pcore_type['mappings'].value) ⇒ CapabilityMapping

Returns a new instance of CapabilityMapping.



4336
4337
4338
4339
4340
4341
4342
4343
# File 'lib/puppet/pops/model/ast.rb', line 4336

def initialize(locator, offset, length, kind, capability, component, mappings = _pcore_type['mappings'].value)
  super(locator, offset, length)
  @hash = @hash ^ kind.hash ^ capability.hash ^ component.hash ^ mappings.hash
  @kind = kind
  @capability = capability
  @component = component
  @mappings = mappings
end

Instance Attribute Details

#capabilityObject (readonly)



4332
4333
4334
# File 'lib/puppet/pops/model/ast.rb', line 4332

def capability
  @capability
end

#componentObject (readonly)



4333
4334
4335
# File 'lib/puppet/pops/model/ast.rb', line 4333

def component
  @component
end

#kindObject (readonly)



4331
4332
4333
# File 'lib/puppet/pops/model/ast.rb', line 4331

def kind
  @kind
end

#mappingsObject (readonly)



4334
4335
4336
# File 'lib/puppet/pops/model/ast.rb', line 4334

def mappings
  @mappings
end

Class Method Details

._pcore_typeObject



4288
4289
4290
4291
4292
4293
4294
4295
4296
4297
4298
4299
4300
4301
# File 'lib/puppet/pops/model/ast.rb', line 4288

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::CapabilityMapping', {
    'parent' => Definition._pcore_type,
    'attributes' => {
      'kind' => Types::PStringType::DEFAULT,
      'capability' => Types::PStringType::DEFAULT,
      'component' => Expression._pcore_type,
      'mappings' => {
        'type' => Types::PArrayType.new(AbstractAttributeOperation._pcore_type),
        'value' => []
      }
    }
  })
end

.create(locator, offset, length, kind, capability, component, mappings = _pcore_type['mappings'].value) ⇒ Object



4318
4319
4320
4321
4322
4323
4324
4325
4326
4327
4328
4329
# File 'lib/puppet/pops/model/ast.rb', line 4318

def self.create(locator, offset, length, kind, capability, component, mappings = _pcore_type['mappings'].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::CapabilityMapping[kind]', attrs['kind'].type, kind)
  ta.assert_instance_of('Puppet::AST::CapabilityMapping[capability]', attrs['capability'].type, capability)
  ta.assert_instance_of('Puppet::AST::CapabilityMapping[component]', attrs['component'].type, component)
  ta.assert_instance_of('Puppet::AST::CapabilityMapping[mappings]', attrs['mappings'].type, mappings)
  new(locator, offset, length, kind, capability, component, mappings)
end

.from_asserted_hash(init_hash) ⇒ Object



4307
4308
4309
4310
4311
4312
4313
4314
4315
4316
# File 'lib/puppet/pops/model/ast.rb', line 4307

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['kind'],
    init_hash['capability'],
    init_hash['component'],
    init_hash.fetch('mappings') { _pcore_type['mappings'].value })
end

.from_hash(init_hash) ⇒ Object



4303
4304
4305
# File 'lib/puppet/pops/model/ast.rb', line 4303

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



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

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

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

Yields:



4354
4355
4356
4357
# File 'lib/puppet/pops/model/ast.rb', line 4354

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

#_pcore_init_hashObject



4345
4346
4347
4348
4349
4350
4351
4352
# File 'lib/puppet/pops/model/ast.rb', line 4345

def _pcore_init_hash
  result = super
  result['kind'] = @kind
  result['capability'] = @capability
  result['component'] = @component
  result['mappings'] = @mappings unless _pcore_type['mappings'].default_value?(@mappings)
  result
end

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

Returns:

  • (Boolean)


4372
4373
4374
4375
4376
4377
4378
# File 'lib/puppet/pops/model/ast.rb', line 4372

def eql?(o)
  super &&
  @kind.eql?(o.kind) &&
  @capability.eql?(o.capability) &&
  @component.eql?(o.component) &&
  @mappings.eql?(o.mappings)
end