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.


4226
4227
4228
4229
4230
4231
# File 'lib/puppet/pops/model/ast.rb', line 4226

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)


4224
4225
4226
# File 'lib/puppet/pops/model/ast.rb', line 4224

def operations
  @operations
end

#resourcesObject (readonly)


4223
4224
4225
# File 'lib/puppet/pops/model/ast.rb', line 4223

def resources
  @resources
end

Class Method Details

._pcore_typeObject


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

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


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

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


4201
4202
4203
4204
4205
4206
4207
4208
4209
# File 'lib/puppet/pops/model/ast.rb', line 4201

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


4197
4198
4199
# File 'lib/puppet/pops/model/ast.rb', line 4197

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


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

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:


4240
4241
4242
4243
# File 'lib/puppet/pops/model/ast.rb', line 4240

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

#_pcore_init_hashObject


4233
4234
4235
4236
4237
4238
# File 'lib/puppet/pops/model/ast.rb', line 4233

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)

4258
4259
4260
4261
4262
# File 'lib/puppet/pops/model/ast.rb', line 4258

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