Class: Puppet::Pops::Model::ResourceBody

Inherits:
Positioned show all
Defined in:
lib/puppet/pops/model/ast.rb

Instance Attribute Summary collapse

Attributes inherited from Positioned

#length, #locator, #offset

Attributes inherited from PopsObject

#hash

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Positioned

#file, #line, #pos

Methods inherited from PopsObject

#to_s

Methods included from Types::PuppetObject

#_pcore_type, #to_s

Constructor Details

#initialize(locator, offset, length, title = nil, operations = _pcore_type['operations'].value) ⇒ ResourceBody

Returns a new instance of ResourceBody.



3988
3989
3990
3991
3992
3993
# File 'lib/puppet/pops/model/ast.rb', line 3988

def initialize(locator, offset, length, title = nil, operations = _pcore_type['operations'].value)
  super(locator, offset, length)
  @hash = @hash ^ title.hash ^ operations.hash
  @title = title
  @operations = operations
end

Instance Attribute Details

#operationsObject (readonly)



3986
3987
3988
# File 'lib/puppet/pops/model/ast.rb', line 3986

def operations
  @operations
end

#titleObject (readonly)



3985
3986
3987
# File 'lib/puppet/pops/model/ast.rb', line 3985

def title
  @title
end

Class Method Details

._pcore_typeObject



3943
3944
3945
3946
3947
3948
3949
3950
3951
3952
3953
3954
3955
3956
3957
3958
3959
# File 'lib/puppet/pops/model/ast.rb', line 3943

def self._pcore_type
  @_pcore_type ||=
    Types::PObjectType
      .new('Puppet::AST::ResourceBody', {
             'parent' => Positioned._pcore_type,
             'attributes' => {
               'title' => {
                 'type' => Types::POptionalType.new(Expression._pcore_type),
                 'value' => nil
               },
               'operations' => {
                 'type' => Types::PArrayType.new(AbstractAttributeOperation._pcore_type),
                 'value' => []
               }
             }
           })
end

.create(locator, offset, length, title = nil, operations = _pcore_type['operations'].value) ⇒ Object



3974
3975
3976
3977
3978
3979
3980
3981
3982
3983
# File 'lib/puppet/pops/model/ast.rb', line 3974

def self.create(locator, offset, length, title = 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::ResourceBody[title]', attrs['title'].type, title)
  ta.assert_instance_of('Puppet::AST::ResourceBody[operations]', attrs['operations'].type, operations)
  new(locator, offset, length, title, operations)
end

.from_asserted_hash(init_hash) ⇒ Object



3965
3966
3967
3968
3969
3970
3971
3972
# File 'lib/puppet/pops/model/ast.rb', line 3965

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['title'],
    init_hash.fetch('operations') { _pcore_type['operations'].value })
end

.from_hash(init_hash) ⇒ Object



3961
3962
3963
# File 'lib/puppet/pops/model/ast.rb', line 3961

def self.from_hash(init_hash)
  from_asserted_hash(Types::TypeAsserter.assert_instance_of('Puppet::AST::ResourceBody initializer', _pcore_type.init_hash_type, init_hash))
end

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



4007
4008
4009
4010
4011
4012
4013
4014
4015
4016
4017
4018
# File 'lib/puppet/pops/model/ast.rb', line 4007

def _pcore_all_contents(path, &block)
  path << self
  unless @title.nil?
    block.call(@title, path)
    @title._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 {|@title| ... } ⇒ Object

Yields:



4002
4003
4004
4005
# File 'lib/puppet/pops/model/ast.rb', line 4002

def _pcore_contents
  yield(@title) unless @title.nil?
  @operations.each { |value| yield(value) }
end

#_pcore_init_hashObject



3995
3996
3997
3998
3999
4000
# File 'lib/puppet/pops/model/ast.rb', line 3995

def _pcore_init_hash
  result = super
  result['title'] = @title unless @title == nil
  result['operations'] = @operations unless _pcore_type['operations'].default_value?(@operations)
  result
end

#eql?(o) ⇒ Boolean Also known as: ==

Returns:

  • (Boolean)


4020
4021
4022
4023
4024
# File 'lib/puppet/pops/model/ast.rb', line 4020

def eql?(o)
  super &&
  @title.eql?(o.title) &&
  @operations.eql?(o.operations)
end