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

Constructor Details

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

Returns a new instance of CapabilityMapping.



4213
4214
4215
4216
4217
4218
4219
4220
# File 'lib/puppet/pops/model/ast.rb', line 4213

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)



4209
4210
4211
# File 'lib/puppet/pops/model/ast.rb', line 4209

def capability
  @capability
end

#componentObject (readonly)



4210
4211
4212
# File 'lib/puppet/pops/model/ast.rb', line 4210

def component
  @component
end

#kindObject (readonly)



4208
4209
4210
# File 'lib/puppet/pops/model/ast.rb', line 4208

def kind
  @kind
end

#mappingsObject (readonly)



4211
4212
4213
# File 'lib/puppet/pops/model/ast.rb', line 4211

def mappings
  @mappings
end

Class Method Details

._pcore_typeObject



4165
4166
4167
4168
4169
4170
4171
4172
4173
4174
4175
4176
4177
4178
# File 'lib/puppet/pops/model/ast.rb', line 4165

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



4195
4196
4197
4198
4199
4200
4201
4202
4203
4204
4205
4206
# File 'lib/puppet/pops/model/ast.rb', line 4195

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



4184
4185
4186
4187
4188
4189
4190
4191
4192
4193
# File 'lib/puppet/pops/model/ast.rb', line 4184

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



4180
4181
4182
# File 'lib/puppet/pops/model/ast.rb', line 4180

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



4236
4237
4238
4239
4240
4241
4242
4243
4244
4245
4246
4247
# File 'lib/puppet/pops/model/ast.rb', line 4236

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:



4231
4232
4233
4234
# File 'lib/puppet/pops/model/ast.rb', line 4231

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

#_pcore_init_hashObject



4222
4223
4224
4225
4226
4227
4228
4229
# File 'lib/puppet/pops/model/ast.rb', line 4222

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)


4249
4250
4251
4252
4253
4254
4255
# File 'lib/puppet/pops/model/ast.rb', line 4249

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