Class: Puppet::Pops::Model::QueryExpression

Inherits:
Expression show all
Defined in:
lib/puppet/pops/model/ast.rb

Direct Known Subclasses

ExportedQuery, VirtualQuery

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, expr = nil) ⇒ QueryExpression

Returns a new instance of QueryExpression.



1426
1427
1428
1429
1430
# File 'lib/puppet/pops/model/ast.rb', line 1426

def initialize(locator, offset, length, expr = nil)
  super(locator, offset, length)
  @hash = @hash ^ expr.hash
  @expr = expr
end

Instance Attribute Details

#exprObject (readonly)



1424
1425
1426
# File 'lib/puppet/pops/model/ast.rb', line 1424

def expr
  @expr
end

Class Method Details

._pcore_typeObject



1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
# File 'lib/puppet/pops/model/ast.rb', line 1390

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::QueryExpression', {
    'parent' => Expression._pcore_type,
    'attributes' => {
      'expr' => {
        'type' => Types::POptionalType.new(Expression._pcore_type),
        'value' => nil
      }
    }
  })
end

.create(locator, offset, length, expr = nil) ⇒ Object



1414
1415
1416
1417
1418
1419
1420
1421
1422
# File 'lib/puppet/pops/model/ast.rb', line 1414

def self.create(locator, offset, length, expr = nil)
  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::QueryExpression[expr]', attrs['expr'].type, expr)
  new(locator, offset, length, expr)
end

.from_asserted_hash(init_hash) ⇒ Object



1406
1407
1408
1409
1410
1411
1412
# File 'lib/puppet/pops/model/ast.rb', line 1406

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['expr'])
end

.from_hash(init_hash) ⇒ Object



1402
1403
1404
# File 'lib/puppet/pops/model/ast.rb', line 1402

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



1442
1443
1444
1445
1446
1447
1448
1449
# File 'lib/puppet/pops/model/ast.rb', line 1442

def _pcore_all_contents(path, &block)
  path << self
  unless @expr.nil?
    block.call(@expr, path)
    @expr._pcore_all_contents(path, &block)
  end
  path.pop
end

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

Yields:



1438
1439
1440
# File 'lib/puppet/pops/model/ast.rb', line 1438

def _pcore_contents
  yield(@expr) unless @expr.nil?
end

#_pcore_init_hashObject



1432
1433
1434
1435
1436
# File 'lib/puppet/pops/model/ast.rb', line 1432

def _pcore_init_hash
  result = super
  result['expr'] = @expr unless @expr == nil
  result
end

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

Returns:

  • (Boolean)


1451
1452
1453
1454
# File 'lib/puppet/pops/model/ast.rb', line 1451

def eql?(o)
  super &&
  @expr.eql?(o.expr)
end