Class: Puppet::Pops::Lookup::Explainer Private

Inherits:
ExplainNode show all
Defined in:
lib/puppet/pops/lookup/explainer.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Direct Known Subclasses

DebugExplainer

Instance Method Summary collapse

Methods inherited from ExplainNode

#branches, #dump_texts, #explain, #inspect, #text, #to_s

Constructor Details

#initialize(explain_options = false, only_explain_options = false) ⇒ Explainer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of Explainer.



464
465
466
467
468
# File 'lib/puppet/pops/lookup/explainer.rb', line 464

def initialize(explain_options = false, only_explain_options = false)
  @current = self
  @explain_options = explain_options
  @only_explain_options = only_explain_options
end

Instance Method Details

#accept_found(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



522
523
524
# File 'lib/puppet/pops/lookup/explainer.rb', line 522

def accept_found(key, value)
  @current.found(key, value)
end

#accept_found_in_defaults(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



518
519
520
# File 'lib/puppet/pops/lookup/explainer.rb', line 518

def accept_found_in_defaults(key, value)
  @current.found_in_defaults(key, value)
end

#accept_found_in_overrides(key, value) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



514
515
516
# File 'lib/puppet/pops/lookup/explainer.rb', line 514

def accept_found_in_overrides(key, value)
  @current.found_in_overrides(key, value)
end

#accept_location_not_foundObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



534
535
536
# File 'lib/puppet/pops/lookup/explainer.rb', line 534

def accept_location_not_found
  @current.location_not_found
end

#accept_merge_source(merge_source) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



526
527
528
# File 'lib/puppet/pops/lookup/explainer.rb', line 526

def accept_merge_source(merge_source)
  @current.branches << ExplainMergeSource.new(merge_source)
end

#accept_module_not_found(module_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



538
539
540
541
542
# File 'lib/puppet/pops/lookup/explainer.rb', line 538

def accept_module_not_found(module_name)
  push(:module, module_name)
  @current.module_not_found
  pop
end

#accept_module_provider_not_found(module_name) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



544
545
546
547
548
# File 'lib/puppet/pops/lookup/explainer.rb', line 544

def accept_module_provider_not_found(module_name)
  push(:module, module_name)
  @current.module_provider_not_found
  pop
end

#accept_not_found(key) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



530
531
532
# File 'lib/puppet/pops/lookup/explainer.rb', line 530

def accept_not_found(key)
  @current.not_found(key)
end

#accept_result(result) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



550
551
552
# File 'lib/puppet/pops/lookup/explainer.rb', line 550

def accept_result(result)
  @current.result(result)
end

#accept_text(text) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



554
555
556
# File 'lib/puppet/pops/lookup/explainer.rb', line 554

def accept_text(text)
  @current.text(text)
end

#dump_on(io, indent, first_indent) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



558
559
560
561
# File 'lib/puppet/pops/lookup/explainer.rb', line 558

def dump_on(io, indent, first_indent)
  branches.each { |b| b.dump_on(io, indent, first_indent) }
  dump_texts(io, indent)
end

#explain_options?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


506
507
508
# File 'lib/puppet/pops/lookup/explainer.rb', line 506

def explain_options?
  @explain_options
end

#only_explain_options?Boolean

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns:

  • (Boolean)


502
503
504
# File 'lib/puppet/pops/lookup/explainer.rb', line 502

def only_explain_options?
  @only_explain_options
end

#popObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



510
511
512
# File 'lib/puppet/pops/lookup/explainer.rb', line 510

def pop
  @current = @current.parent unless @current.parent.nil?
end

#push(qualifier_type, qualifier) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
# File 'lib/puppet/pops/lookup/explainer.rb', line 470

def push(qualifier_type, qualifier)
  node = case (qualifier_type)
    when :global
     ExplainGlobal.new(@current, qualifier)
    when :location
      ExplainLocation.new(@current, qualifier)
    when :interpolate
      ExplainInterpolate.new(@current, qualifier)
    when :data_provider
      ExplainDataProvider.new(@current, qualifier)
    when :merge
      ExplainMerge.new(@current, qualifier)
    when :module
      ExplainModule.new(@current, qualifier)
    when :scope
      ExplainScope.new(@current, qualifier)
    when :sub_lookup
      ExplainSubLookup.new(@current, qualifier)
    when :segment
      ExplainKeySegment.new(@current, qualifier)
    when :meta, :data
      ExplainTop.new(@current, qualifier_type, qualifier)
    when :invalid_key
      ExplainInvalidKey.new(@current, qualifier)
    else
      #TRANSLATORS 'Explain' is referring to the 'Explainer' class and should not be translated
      raise ArgumentError, _("Unknown Explain type %{qualifier_type}") % { qualifier_type: qualifier_type }
    end
  @current.branches << node
  @current = node
end

#to_hashObject

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



563
564
565
# File 'lib/puppet/pops/lookup/explainer.rb', line 563

def to_hash
  branches.size == 1 ? branches[0].to_hash : super
end