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