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.
1736 1737 1738 1739 1740 1741 1742 |
# File 'lib/puppet/pops/model/ast.rb', line 1736 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)
1734 1735 1736 |
# File 'lib/puppet/pops/model/ast.rb', line 1734 def operations @operations end |
#query ⇒ Object (readonly)
1733 1734 1735 |
# File 'lib/puppet/pops/model/ast.rb', line 1733 def query @query end |
#type_expr ⇒ Object (readonly)
1732 1733 1734 |
# File 'lib/puppet/pops/model/ast.rb', line 1732 def type_expr @type_expr end |
Class Method Details
._pcore_type ⇒ Object
1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700 1701 1702 1703 1704 |
# File 'lib/puppet/pops/model/ast.rb', line 1690 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
1720 1721 1722 1723 1724 1725 1726 1727 1728 1729 1730 |
# File 'lib/puppet/pops/model/ast.rb', line 1720 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
1710 1711 1712 1713 1714 1715 1716 1717 1718 |
# File 'lib/puppet/pops/model/ast.rb', line 1710 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
1706 1707 1708 |
# File 'lib/puppet/pops/model/ast.rb', line 1706 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
1758 1759 1760 1761 1762 1763 1764 1765 1766 1767 1768 1769 1770 1771 1772 1773 |
# File 'lib/puppet/pops/model/ast.rb', line 1758 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
1752 1753 1754 1755 1756 |
# File 'lib/puppet/pops/model/ast.rb', line 1752 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
1744 1745 1746 1747 1748 1749 1750 |
# File 'lib/puppet/pops/model/ast.rb', line 1744 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: ==
1775 1776 1777 1778 1779 1780 |
# File 'lib/puppet/pops/model/ast.rb', line 1775 def eql?(o) super && @type_expr.eql?(o.type_expr) && @query.eql?(o.query) && @operations.eql?(o.operations) end |