Class: Puppet::Pops::Model::SiteDefinition

Inherits:
Definition 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, body = nil) ⇒ SiteDefinition

Returns a new instance of SiteDefinition.



2498
2499
2500
2501
2502
# File 'lib/puppet/pops/model/ast.rb', line 2498

def initialize(locator, offset, length, body = nil)
  super(locator, offset, length)
  @hash = @hash ^ body.hash
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)



2496
2497
2498
# File 'lib/puppet/pops/model/ast.rb', line 2496

def body
  @body
end

Class Method Details

._pcore_typeObject



2462
2463
2464
2465
2466
2467
2468
2469
2470
2471
2472
# File 'lib/puppet/pops/model/ast.rb', line 2462

def self._pcore_type
  @_pcore_type ||= Types::PObjectType.new('Puppet::AST::SiteDefinition', {
    'parent' => Definition._pcore_type,
    'attributes' => {
      'body' => {
        'type' => Types::POptionalType.new(Expression._pcore_type),
        'value' => nil
      }
    }
  })
end

.create(locator, offset, length, body = nil) ⇒ Object



2486
2487
2488
2489
2490
2491
2492
2493
2494
# File 'lib/puppet/pops/model/ast.rb', line 2486

def self.create(locator, offset, length, body = nil)
  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::SiteDefinition[body]', attrs['body'].type, body)
  new(locator, offset, length, body)
end

.from_asserted_hash(init_hash) ⇒ Object



2478
2479
2480
2481
2482
2483
2484
# File 'lib/puppet/pops/model/ast.rb', line 2478

def self.from_asserted_hash(init_hash)
  new(
    init_hash['locator'],
    init_hash['offset'],
    init_hash['length'],
    init_hash['body'])
end

.from_hash(init_hash) ⇒ Object



2474
2475
2476
# File 'lib/puppet/pops/model/ast.rb', line 2474

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

Instance Method Details

#_pcore_all_contents(path, &block) ⇒ Object



2514
2515
2516
2517
2518
2519
2520
2521
# File 'lib/puppet/pops/model/ast.rb', line 2514

def _pcore_all_contents(path, &block)
  path << self
  unless @body.nil?
    block.call(@body, path)
    @body._pcore_all_contents(path, &block)
  end
  path.pop
end

#_pcore_contents {|@body| ... } ⇒ Object

Yields:



2510
2511
2512
# File 'lib/puppet/pops/model/ast.rb', line 2510

def _pcore_contents
  yield(@body) unless @body.nil?
end

#_pcore_init_hashObject



2504
2505
2506
2507
2508
# File 'lib/puppet/pops/model/ast.rb', line 2504

def _pcore_init_hash
  result = super
  result['body'] = @body unless @body == nil
  result
end

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

Returns:

  • (Boolean)


2523
2524
2525
2526
# File 'lib/puppet/pops/model/ast.rb', line 2523

def eql?(o)
  super &&
  @body.eql?(o.body)
end