Class: Puppet::Pops::Model::FunctionDefinition
- Inherits:
-
NamedDefinition
- Object
- PopsObject
- Positioned
- Expression
- Definition
- NamedDefinition
- Puppet::Pops::Model::FunctionDefinition
- Defined in:
- lib/puppet/pops/model/ast.rb
Direct Known Subclasses
Instance Attribute Summary collapse
- #return_type ⇒ Object readonly
Attributes inherited from NamedDefinition
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, name, 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, name, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) ⇒ FunctionDefinition
constructor
A new instance of FunctionDefinition.
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, name, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) ⇒ FunctionDefinition
Returns a new instance of FunctionDefinition.
2033 2034 2035 2036 2037 |
# File 'lib/puppet/pops/model/ast.rb', line 2033 def initialize(locator, offset, length, name, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) super(locator, offset, length, name, parameters, body) @hash = @hash ^ return_type.hash @return_type = return_type end |
Instance Attribute Details
#return_type ⇒ Object (readonly)
2031 2032 2033 |
# File 'lib/puppet/pops/model/ast.rb', line 2031 def return_type @return_type end |
Class Method Details
._pcore_type ⇒ Object
1989 1990 1991 1992 1993 1994 1995 1996 1997 1998 1999 2000 2001 |
# File 'lib/puppet/pops/model/ast.rb', line 1989 def self._pcore_type @_pcore_type ||= Types::PObjectType .new('Puppet::AST::FunctionDefinition', { 'parent' => NamedDefinition._pcore_type, 'attributes' => { 'return_type' => { 'type' => Types::POptionalType.new(Expression._pcore_type), 'value' => nil } } }) end |
.create(locator, offset, length, name, parameters = _pcore_type['parameters'].value, body = nil, return_type = nil) ⇒ Object
2018 2019 2020 2021 2022 2023 2024 2025 2026 2027 2028 2029 |
# File 'lib/puppet/pops/model/ast.rb', line 2018 def self.create(locator, offset, length, name, 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::NamedDefinition[name]', attrs['name'].type, name) ta.assert_instance_of('Puppet::AST::NamedDefinition[parameters]', attrs['parameters'].type, parameters) ta.assert_instance_of('Puppet::AST::NamedDefinition[body]', attrs['body'].type, body) ta.assert_instance_of('Puppet::AST::FunctionDefinition[return_type]', attrs['return_type'].type, return_type) new(locator, offset, length, name, parameters, body, return_type) end |
.from_asserted_hash(init_hash) ⇒ Object
2007 2008 2009 2010 2011 2012 2013 2014 2015 2016 |
# File 'lib/puppet/pops/model/ast.rb', line 2007 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['name'], init_hash.fetch('parameters') { _pcore_type['parameters'].value }, init_hash['body'], init_hash['return_type']) end |
.from_hash(init_hash) ⇒ Object
2003 2004 2005 |
# File 'lib/puppet/pops/model/ast.rb', line 2003 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::FunctionDefinition initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
2051 2052 2053 2054 2055 2056 2057 2058 2059 2060 2061 2062 2063 2064 2065 2066 |
# File 'lib/puppet/pops/model/ast.rb', line 2051 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
2045 2046 2047 2048 2049 |
# File 'lib/puppet/pops/model/ast.rb', line 2045 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
2039 2040 2041 2042 2043 |
# File 'lib/puppet/pops/model/ast.rb', line 2039 def _pcore_init_hash result = super result['return_type'] = @return_type unless @return_type == nil result end |
#eql?(o) ⇒ Boolean Also known as: ==
2068 2069 2070 2071 |
# File 'lib/puppet/pops/model/ast.rb', line 2068 def eql?(o) super && @return_type.eql?(o.return_type) end |