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

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

Instance Method Summary collapse

Methods inherited from ExplainNode

#branches, #to_s

Constructor Details

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

Returns a new instance of Explainer.



387
388
389
390
391
# File 'lib/puppet/pops/lookup/explainer.rb', line 387

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



440
441
442
# File 'lib/puppet/pops/lookup/explainer.rb', line 440

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

#accept_found_in_defaults(key, value) ⇒ Object



436
437
438
# File 'lib/puppet/pops/lookup/explainer.rb', line 436

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

#accept_found_in_overrides(key, value) ⇒ Object



432
433
434
# File 'lib/puppet/pops/lookup/explainer.rb', line 432

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

#accept_merge_source(merge_source) ⇒ Object



444
445
446
# File 'lib/puppet/pops/lookup/explainer.rb', line 444

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

#accept_module_not_foundObject



456
457
458
# File 'lib/puppet/pops/lookup/explainer.rb', line 456

def accept_module_not_found
  @current.module_not_found
end

#accept_not_found(key) ⇒ Object



448
449
450
# File 'lib/puppet/pops/lookup/explainer.rb', line 448

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

#accept_path_not_foundObject



452
453
454
# File 'lib/puppet/pops/lookup/explainer.rb', line 452

def accept_path_not_found
  @current.path_not_found
end

#accept_result(result) ⇒ Object



460
461
462
# File 'lib/puppet/pops/lookup/explainer.rb', line 460

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

#dump_on(io, indent, first_indent) ⇒ Object



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

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

#explain_options?Boolean

Returns:

  • (Boolean)


424
425
426
# File 'lib/puppet/pops/lookup/explainer.rb', line 424

def explain_options?
  @explain_options
end

#only_explain_options?Boolean

Returns:

  • (Boolean)


420
421
422
# File 'lib/puppet/pops/lookup/explainer.rb', line 420

def only_explain_options?
  @only_explain_options
end

#popObject



428
429
430
# File 'lib/puppet/pops/lookup/explainer.rb', line 428

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

#push(qualifier_type, qualifier) ⇒ Object



393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
# File 'lib/puppet/pops/lookup/explainer.rb', line 393

def push(qualifier_type, qualifier)
  node = case (qualifier_type)
    when :global
     ExplainGlobal.new(@current, qualifier)
    when :path
      ExplainPath.new(@current, qualifier)
    when :module
      ExplainModule.new(@current, qualifier)
    when :interpolate
      ExplainInterpolate.new(@current, qualifier)
    when :data_provider
      ExplainDataProvider.new(@current, qualifier)
    when :merge
      ExplainMerge.new(@current, qualifier)
    when :scope
      ExplainScope.new(@current)
    when :meta, :data
      ExplainTop.new(@current, qualifier_type, qualifier)
    when :invalid_key
      ExplainInvalidKey.new(@current, qualifier)
    else
      raise ArgumentError, "Unknown Explain type #{qualifier_type}"
    end
  @current.branches << node
  @current = node
end

#to_hashObject



468
469
470
# File 'lib/puppet/pops/lookup/explainer.rb', line 468

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