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

#initializeExplainer

Returns a new instance of Explainer.



335
336
337
# File 'lib/puppet/pops/lookup/explainer.rb', line 335

def initialize
  @current = self
end

Instance Method Details

#accept_found(key, value) ⇒ Object



374
375
376
# File 'lib/puppet/pops/lookup/explainer.rb', line 374

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

#accept_found_in_defaults(key, value) ⇒ Object



370
371
372
# File 'lib/puppet/pops/lookup/explainer.rb', line 370

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

#accept_found_in_overrides(key, value) ⇒ Object



366
367
368
# File 'lib/puppet/pops/lookup/explainer.rb', line 366

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

#accept_module_not_foundObject



386
387
388
# File 'lib/puppet/pops/lookup/explainer.rb', line 386

def accept_module_not_found
  @current.module_not_found
end

#accept_not_found(key) ⇒ Object



378
379
380
# File 'lib/puppet/pops/lookup/explainer.rb', line 378

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

#accept_path_not_foundObject



382
383
384
# File 'lib/puppet/pops/lookup/explainer.rb', line 382

def accept_path_not_found
  @current.path_not_found
end

#accept_result(result) ⇒ Object



390
391
392
# File 'lib/puppet/pops/lookup/explainer.rb', line 390

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

#dump_on(io, indent, first_indent) ⇒ Object



394
395
396
# File 'lib/puppet/pops/lookup/explainer.rb', line 394

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

#popObject



362
363
364
# File 'lib/puppet/pops/lookup/explainer.rb', line 362

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

#push(qualifier_type, qualifier) ⇒ Object



339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
# File 'lib/puppet/pops/lookup/explainer.rb', line 339

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)
    else
      raise ArgumentError, "Unknown Explain type #{qualifier_type}"
    end
  @current.branches << node
  @current = node
end

#to_hashObject



398
399
400
# File 'lib/puppet/pops/lookup/explainer.rb', line 398

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