Class: Puppet::Pops::Model::ResourceExpression
- Inherits:
-
AbstractResource
- Object
- PopsObject
- Positioned
- Expression
- AbstractResource
- Puppet::Pops::Model::ResourceExpression
- Defined in:
- lib/puppet/pops/model/ast.rb
Instance Attribute Summary collapse
- #bodies ⇒ Object readonly
- #type_name ⇒ Object readonly
Attributes inherited from AbstractResource
Attributes inherited from Positioned
Attributes inherited from PopsObject
Class Method Summary collapse
- ._pcore_type ⇒ Object
- .create(locator, offset, length, type_name, form = "regular", bodies = _pcore_type['bodies'].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_name| ... } ⇒ Object
- #_pcore_init_hash ⇒ Object
- #eql?(o) ⇒ Boolean (also: #==)
-
#initialize(locator, offset, length, type_name, form = "regular", bodies = _pcore_type['bodies'].value) ⇒ ResourceExpression
constructor
A new instance of ResourceExpression.
Methods inherited from AbstractResource
Methods inherited from Positioned
Methods inherited from PopsObject
Methods included from Types::PuppetObject
Constructor Details
#initialize(locator, offset, length, type_name, form = "regular", bodies = _pcore_type['bodies'].value) ⇒ ResourceExpression
Returns a new instance of ResourceExpression.
4147 4148 4149 4150 4151 4152 |
# File 'lib/puppet/pops/model/ast.rb', line 4147 def initialize(locator, offset, length, type_name, form = "regular", bodies = _pcore_type['bodies'].value) super(locator, offset, length, form) @hash = @hash ^ type_name.hash ^ bodies.hash @type_name = type_name @bodies = bodies end |
Instance Attribute Details
#bodies ⇒ Object (readonly)
4145 4146 4147 |
# File 'lib/puppet/pops/model/ast.rb', line 4145 def bodies @bodies end |
#type_name ⇒ Object (readonly)
4144 4145 4146 |
# File 'lib/puppet/pops/model/ast.rb', line 4144 def type_name @type_name end |
Class Method Details
._pcore_type ⇒ Object
4103 4104 4105 4106 4107 4108 4109 4110 4111 4112 4113 4114 4115 4116 |
# File 'lib/puppet/pops/model/ast.rb', line 4103 def self._pcore_type @_pcore_type ||= Types::PObjectType .new('Puppet::AST::ResourceExpression', { 'parent' => AbstractResource._pcore_type, 'attributes' => { 'type_name' => Expression._pcore_type, 'bodies' => { 'type' => Types::PArrayType.new(ResourceBody._pcore_type), 'value' => [] } } }) end |
.create(locator, offset, length, type_name, form = "regular", bodies = _pcore_type['bodies'].value) ⇒ Object
4132 4133 4134 4135 4136 4137 4138 4139 4140 4141 4142 |
# File 'lib/puppet/pops/model/ast.rb', line 4132 def self.create(locator, offset, length, type_name, form = "regular", bodies = _pcore_type['bodies'].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::AbstractResource[form]', attrs['form'].type, form) ta.assert_instance_of('Puppet::AST::ResourceExpression[type_name]', attrs['type_name'].type, type_name) ta.assert_instance_of('Puppet::AST::ResourceExpression[bodies]', attrs['bodies'].type, bodies) new(locator, offset, length, type_name, form, bodies) end |
.from_asserted_hash(init_hash) ⇒ Object
4122 4123 4124 4125 4126 4127 4128 4129 4130 |
# File 'lib/puppet/pops/model/ast.rb', line 4122 def self.from_asserted_hash(init_hash) new( init_hash['locator'], init_hash['offset'], init_hash['length'], init_hash['type_name'], init_hash.fetch('form') { "regular" }, init_hash.fetch('bodies') { _pcore_type['bodies'].value }) end |
.from_hash(init_hash) ⇒ Object
4118 4119 4120 |
# File 'lib/puppet/pops/model/ast.rb', line 4118 def self.from_hash(init_hash) from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::ResourceExpression initializer', _pcore_type.init_hash_type, init_hash)) end |
Instance Method Details
#_pcore_all_contents(path, &block) ⇒ Object
4166 4167 4168 4169 4170 4171 4172 4173 4174 4175 4176 4177 |
# File 'lib/puppet/pops/model/ast.rb', line 4166 def _pcore_all_contents(path, &block) path << self unless @type_name.nil? block.call(@type_name, path) @type_name._pcore_all_contents(path, &block) end @bodies.each do |value| block.call(value, path) value._pcore_all_contents(path, &block) end path.pop end |
#_pcore_contents {|@type_name| ... } ⇒ Object
4161 4162 4163 4164 |
# File 'lib/puppet/pops/model/ast.rb', line 4161 def _pcore_contents yield(@type_name) unless @type_name.nil? @bodies.each { |value| yield(value) } end |
#_pcore_init_hash ⇒ Object
4154 4155 4156 4157 4158 4159 |
# File 'lib/puppet/pops/model/ast.rb', line 4154 def _pcore_init_hash result = super result['type_name'] = @type_name result['bodies'] = @bodies unless _pcore_type['bodies'].default_value?(@bodies) result end |
#eql?(o) ⇒ Boolean Also known as: ==
4179 4180 4181 4182 4183 |
# File 'lib/puppet/pops/model/ast.rb', line 4179 def eql?(o) super && @type_name.eql?(o.type_name) && @bodies.eql?(o.bodies) end |