Class: Puppet::Pops::Model::LambdaExpression
- Inherits:
-
Expression
- Object
- PopsObject
- Positioned
- Expression
- Puppet::Pops::Model::LambdaExpression
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #body ⇒ Object readonly
- #parameters ⇒ Object readonly
- #return_type ⇒ Object readonly
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) ⇒ Object
- .from_asserted_hash(init_hash) ⇒ Object
- .from_hash(init_hash) ⇒ Object
Instance Method Summary collapse
- #_pcore_all_contents(path, &block) ⇒ Object
- #_pcore_contents {|@body| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) ⇒ LambdaExpression
constructor
A new instance of LambdaExpression.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) ⇒ LambdaExpression
Returns a new instance of LambdaExpression.
2740 2741 2742 2743 2744 2745 2746 |
# File 'lib/puppet/pops/model/ast.rb', line 2740 def initialize(locator, offset, length, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) super(locator, offset, length) @hash = @hash ^ parameters.hash ^ body.hash ^ return_type.hash @parameters = parameters @body = body @return_type = return_type end |
Instance Attribute Details
#body ⇒ Object (readonly)
2737 2738 2739 |
# File 'lib/puppet/pops/model/ast.rb', line 2737 def body @body end |
#parameters ⇒ Object (readonly)
2736 2737 2738 |
# File 'lib/puppet/pops/model/ast.rb', line 2736 def parameters @parameters end |
#return_type ⇒ Object (readonly)
2738 2739 2740 |
# File 'lib/puppet/pops/model/ast.rb', line 2738 def return_type @return_type end |
Class Method Details
._pcore_type ⇒ Object
2688 2689 2690 2691 2692 2693 2694 2695 2696 2697 2698 2699 2700 2701 2702 2703 2704 2705 2706 2707 2708 |
# File 'lib/puppet/pops/model/ast.rb', line 2688 def self._pcore_type @_pcore_type ||= Types::PObjectType .new('Puppet::AST::LambdaExpression', { 'parent' => Expression._pcore_type, 'attributes' => { 'parameters' => { 'type' => Types::PArrayType.new(Parameter._pcore_type), 'value' => [] }, 'body' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil }, 'return_type' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil } } }) end |
.create(locator, offset, length, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) ⇒ Object
2724 2725 2726 2727 2728 2729 2730 2731 2732 2733 2734 |
# File 'lib/puppet/pops/model/ast.rb', line 2724 def self.create(locator, offset, length, parameters = _pcore_type['parameters'].value, body = nil, return_type = 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::LambdaExpression[parameters]', attrs['parameters'].type, parameters) ta.assert_instance_of('Puppet::AST::LambdaExpression[body]', attrs['body'].type, body) ta.assert_instance_of('Puppet::AST::LambdaExpression[return_type]', attrs['return_type'].type, return_type) new(locator, offset, length, parameters, body, return_type) end |
.from_asserted_hash(init_hash) ⇒ Object
2714 2715 2716 2717 2718 2719 2720 2721 2722 |
# File 'lib/puppet/pops/model/ast.rb', line 2714 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash.fetch('parameters') { _pcore_type['parameters'].value }, init_hash['body'], init_hash['return_type']) end |
.from_hash(init_hash) ⇒ Object
2710 2711 2712 |
# File 'lib/puppet/pops/model/ast.rb', line 2710 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::LambdaExpression initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
2762 2763 2764 2765 2766 2767 2768 2769 2770 2771 2772 2773 2774 2775 2776 2777 |
# File 'lib/puppet/pops/model/ast.rb', line 2762 def _pcore_all_contents(path, &block) path << self @parameters.each do |value| block.call(value, path) value._pcore_all_contents(path, &block) end unless @body.nil? block.call(@body, path) @body._pcore_all_contents(path, &block) end unless @return_type.nil? block.call(@return_type, path) @return_type._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@body| ... } ⇒ Object
2756 2757 2758 2759 2760 |
# File 'lib/puppet/pops/model/ast.rb', line 2756 def _pcore_contents @parameters.each { |value| yield(value) } yield(@body) unless @body.nil? yield(@return_type) unless @return_type.nil? end |
#_pcore_init_hash ⇒ Object
2748 2749 2750 2751 2752 2753 2754 |
# File 'lib/puppet/pops/model/ast.rb', line 2748 def _pcore_init_hash result = super result['parameters'] = @parameters unless _pcore_type['parameters'].default_value?(@parameters) result['body'] = @body unless @body == nil result['return_type'] = @return_type unless @return_type == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
2779 2780 2781 2782 2783 2784 |
# File 'lib/puppet/pops/model/ast.rb', line 2779 def eql?(o) super && @parameters.eql?(o.parameters) && @body.eql?(o.body) && @return_type.eql?(o.return_type) end |