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

Constructor Details

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

Returns a new instance of ResourceBody.



3969
3970
3971
3972
3973
3974
# File 'lib/puppet/pops/model/ast.rb', line 3969

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)



3967
3968
3969
# File 'lib/puppet/pops/model/ast.rb', line 3967

def operations
  @operations
end

#titleObject (readonly)



3966
3967
3968
# File 'lib/puppet/pops/model/ast.rb', line 3966

def title
  @title
end

Class Method Details

._pcore_typeObject



3926
3927
3928
3929
3930
3931
3932
3933
3934
3935
3936
3937
3938
3939
3940
# File 'lib/puppet/pops/model/ast.rb', line 3926

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



3955
3956
3957
3958
3959
3960
3961
3962
3963
3964
# File 'lib/puppet/pops/model/ast.rb', line 3955

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



3946
3947
3948
3949
3950
3951
3952
3953
# File 'lib/puppet/pops/model/ast.rb', line 3946

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



3942
3943
3944
# File 'lib/puppet/pops/model/ast.rb', line 3942

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



3988
3989
3990
3991
3992
3993
3994
3995
3996
3997
3998
3999
# File 'lib/puppet/pops/model/ast.rb', line 3988

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:



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

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

#_pcore_init_hashObject



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

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)


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

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