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

Constructor Details

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

Returns a new instance of ResourceDefaultsExpression.



4305
4306
4307
4308
4309
4310
# File 'lib/puppet/pops/model/ast.rb', line 4305

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)



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

def operations
  @operations
end

#type_refObject (readonly)



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

def type_ref
  @type_ref
end

Class Method Details

._pcore_typeObject



4260
4261
4262
4263
4264
4265
4266
4267
4268
4269
4270
4271
4272
4273
4274
# File 'lib/puppet/pops/model/ast.rb', line 4260

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



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

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



4280
4281
4282
4283
4284
4285
4286
4287
4288
# File 'lib/puppet/pops/model/ast.rb', line 4280

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



4276
4277
4278
# File 'lib/puppet/pops/model/ast.rb', line 4276

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



4324
4325
4326
4327
4328
4329
4330
4331
4332
4333
4334
4335
# File 'lib/puppet/pops/model/ast.rb', line 4324

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:



4319
4320
4321
4322
# File 'lib/puppet/pops/model/ast.rb', line 4319

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

#_pcore_init_hashObject



4312
4313
4314
4315
4316
4317
# File 'lib/puppet/pops/model/ast.rb', line 4312

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: ==

Returns:

  • (Boolean)


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

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