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

Constructor Details

#initialize(locator, offset, length, expr = nil) ⇒ QueryExpression

Returns a new instance of QueryExpression.



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

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

Instance Attribute Details

#exprObject (readonly)



1416
1417
1418
# File 'lib/puppet/pops/model/ast.rb', line 1416

def expr
  @expr
end

Class Method Details

._pcore_typeObject



1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
# File 'lib/puppet/pops/model/ast.rb', line 1382

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



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

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



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

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



1394
1395
1396
# File 'lib/puppet/pops/model/ast.rb', line 1394

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



1434
1435
1436
1437
1438
1439
1440
1441
# File 'lib/puppet/pops/model/ast.rb', line 1434

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:



1430
1431
1432
# File 'lib/puppet/pops/model/ast.rb', line 1430

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

#_pcore_init_hashObject



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

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

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

Returns:

  • (Boolean)


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

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