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

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

Overview

API:

  • public

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.

API:

  • public



4093
4094
4095
4096
4097
4098
# File 'lib/puppet/pops/model/ast.rb', line 4093

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)

API:

  • public



4091
4092
4093
# File 'lib/puppet/pops/model/ast.rb', line 4091

def operations
  @operations
end

#titleObject (readonly)

API:

  • public



4090
4091
4092
# File 'lib/puppet/pops/model/ast.rb', line 4090

def title
  @title
end

Class Method Details

._pcore_typeObject

API:

  • public



4050
4051
4052
4053
4054
4055
4056
4057
4058
4059
4060
4061
4062
4063
4064
# File 'lib/puppet/pops/model/ast.rb', line 4050

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

API:

  • public



4079
4080
4081
4082
4083
4084
4085
4086
4087
4088
# File 'lib/puppet/pops/model/ast.rb', line 4079

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

API:

  • public



4070
4071
4072
4073
4074
4075
4076
4077
# File 'lib/puppet/pops/model/ast.rb', line 4070

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

API:

  • public



4066
4067
4068
# File 'lib/puppet/pops/model/ast.rb', line 4066

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

API:

  • public



4112
4113
4114
4115
4116
4117
4118
4119
4120
4121
4122
4123
# File 'lib/puppet/pops/model/ast.rb', line 4112

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:

API:

  • public



4107
4108
4109
4110
# File 'lib/puppet/pops/model/ast.rb', line 4107

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

#_pcore_init_hashObject

API:

  • public



4100
4101
4102
4103
4104
4105
# File 'lib/puppet/pops/model/ast.rb', line 4100

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:

API:

  • public



4125
4126
4127
4128
4129
# File 'lib/puppet/pops/model/ast.rb', line 4125

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