Class: Puppet::Pops::Model::AttributesOperation

Inherits:
AbstractAttributeOperation 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, expr) ⇒ AttributesOperation

Returns a new instance of AttributesOperation.



1614
1615
1616
1617
1618
# File 'lib/puppet/pops/model/ast.rb', line 1614

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

Instance Attribute Details

#exprObject (readonly)



1612
1613
1614
# File 'lib/puppet/pops/model/ast.rb', line 1612

def expr
  @expr
end

Class Method Details

._pcore_typeObject



1581
1582
1583
1584
1585
1586
1587
1588
# File 'lib/puppet/pops/model/ast.rb', line 1581

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::AttributesOperation', {
    'parent' => AbstractAttributeOperation._pcore_type,
    'attributes' => {
      'expr' => Expression._pcore_type
    }
  })
end

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



1602
1603
1604
1605
1606
1607
1608
1609
1610
# File 'lib/puppet/pops/model/ast.rb', line 1602

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

.from_asserted_hash(init_hash) ⇒ Object



1594
1595
1596
1597
1598
1599
1600
# File 'lib/puppet/pops/model/ast.rb', line 1594

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



1590
1591
1592
# File 'lib/puppet/pops/model/ast.rb', line 1590

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



1630
1631
1632
1633
1634
1635
1636
1637
# File 'lib/puppet/pops/model/ast.rb', line 1630

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:



1626
1627
1628
# File 'lib/puppet/pops/model/ast.rb', line 1626

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

#_pcore_init_hashObject



1620
1621
1622
1623
1624
# File 'lib/puppet/pops/model/ast.rb', line 1620

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

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

Returns:

  • (Boolean)


1639
1640
1641
1642
# File 'lib/puppet/pops/model/ast.rb', line 1639

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