Class: Puppet::Pops::Model::CollectExpression
- Inherits:
-
Expression
- Object
- PopsObject
- Positioned
- Expression
- Puppet::Pops::Model::CollectExpression
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #operations ⇒ Object readonly
- #query ⇒ Object readonly
- #type_expr ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, type_expr, query, operations = _pcore_type['operations'].value) ⇒ Object
- .from_asserted_hash(init_hash) ⇒ Object
- .from_hash(init_hash) ⇒ Object
Instance Method Summary collapse
- #_pcore_all_contents(path, &block) ⇒ Object
- #_pcore_contents {|@type_expr| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, type_expr, query, operations = _pcore_type['operations'].value) ⇒ CollectExpression
constructor
A new instance of CollectExpression.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, type_expr, query, operations = _pcore_type['operations'].value) ⇒ CollectExpression
Returns a new instance of CollectExpression.
1691 1692 1693 1694 1695 1696 1697 |
# File 'lib/puppet/pops/model/ast.rb', line 1691 def initialize(locator, offset, length, type_expr, query, operations = _pcore_type['operations'].value) super(locator, offset, length) @hash = @hash ^ type_expr.hash ^ query.hash ^ operations.hash @type_expr = type_expr @query = query @operations = operations end |
Instance Attribute Details
#operations ⇒ Object (readonly)
1689 1690 1691 |
# File 'lib/puppet/pops/model/ast.rb', line 1689 def operations @operations end |
#query ⇒ Object (readonly)
1688 1689 1690 |
# File 'lib/puppet/pops/model/ast.rb', line 1688 def query @query end |
#type_expr ⇒ Object (readonly)
1687 1688 1689 |
# File 'lib/puppet/pops/model/ast.rb', line 1687 def type_expr @type_expr end |
Class Method Details
._pcore_type ⇒ Object
1647 1648 1649 1650 1651 1652 1653 1654 1655 1656 1657 1658 1659 |
# File 'lib/puppet/pops/model/ast.rb', line 1647 def self._pcore_type @_pcore_type ||= Types::PObjectType.new('Puppet::AST::CollectExpression', { 'parent' => Expression._pcore_type, 'attributes' => { 'type_expr' => Expression._pcore_type, 'query' => QueryExpression._pcore_type, 'operations' => { 'type' => Types::PArrayType.new(AbstractAttributeOperation._pcore_type), 'value' => [] } } }) end |
.create(locator, offset, length, type_expr, query, operations = _pcore_type['operations'].value) ⇒ Object
1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 |
# File 'lib/puppet/pops/model/ast.rb', line 1675 def self.create(locator, offset, length, type_expr, query, 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::CollectExpression[type_expr]', attrs['type_expr'].type, type_expr) ta.assert_instance_of('Puppet::AST::CollectExpression[query]', attrs['query'].type, query) ta.assert_instance_of('Puppet::AST::CollectExpression[operations]', attrs['operations'].type, operations) new(locator, offset, length, type_expr, query, operations) end |
.from_asserted_hash(init_hash) ⇒ Object
1665 1666 1667 1668 1669 1670 1671 1672 1673 |
# File 'lib/puppet/pops/model/ast.rb', line 1665 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['type_expr'], init_hash['query'], init_hash.fetch('operations') { _pcore_type['operations'].value }) end |
.from_hash(init_hash) ⇒ Object
1661 1662 1663 |
# File 'lib/puppet/pops/model/ast.rb', line 1661 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::CollectExpression initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
1713 1714 1715 1716 1717 1718 1719 1720 1721 1722 1723 1724 1725 1726 1727 1728 |
# File 'lib/puppet/pops/model/ast.rb', line 1713 def _pcore_all_contents(path, &block) path << self unless @type_expr.nil? block.call(@type_expr, path) @type_expr._pcore_all_contents(path, &block) end unless @query.nil? block.call(@query, path) @query._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_expr| ... } ⇒ Object
1707 1708 1709 1710 1711 |
# File 'lib/puppet/pops/model/ast.rb', line 1707 def _pcore_contents yield(@type_expr) unless @type_expr.nil? yield(@query) unless @query.nil? @operations.each { |value| yield(value) } end |
#_pcore_init_hash ⇒ Object
1699 1700 1701 1702 1703 1704 1705 |
# File 'lib/puppet/pops/model/ast.rb', line 1699 def _pcore_init_hash result = super result['type_expr'] = @type_expr result['query'] = @query result['operations'] = @operations unless _pcore_type['operations'].default_value?(@operations) result end |
#eql?(o) ⇒ Boolean Also known as: ==
1730 1731 1732 1733 1734 1735 |
# File 'lib/puppet/pops/model/ast.rb', line 1730 def eql?(o) super && @type_expr.eql?(o.type_expr) && @query.eql?(o.query) && @operations.eql?(o.operations) end |