Method: Puppet::Parser::Scope#lookup_qualified_variable

Defined in:
lib/puppet/parser/scope.rb

#lookup_qualified_variable(fqn, options) ⇒ 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.



604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
# File 'lib/puppet/parser/scope.rb', line 604

def lookup_qualified_variable(fqn, options)
  table = @compiler.qualified_variables
  val = table[fqn]
  return val if !val.nil? || table.include?(fqn)

  # not found - search inherited scope for class
  leaf_index = fqn.rindex('::')
  unless leaf_index.nil?
    leaf_name = fqn[(leaf_index + 2)..]
    class_name = fqn[0, leaf_index]
    begin
      qs = qualified_scope(class_name)
      unless qs.nil?
        return qs.get_local_variable(leaf_name) if qs.has_local_variable?(leaf_name)

        iscope = qs.inherited_scope
        return lookup_qualified_variable("#{iscope.source.name}::#{leaf_name}", options) unless iscope.nil?
      end
    rescue RuntimeError => e
      # because a failure to find the class, or inherited should be reported against given name
      return handle_not_found(class_name, leaf_name, options, e.message)
    end
  end
  # report with leading '::' by using empty class_name
  handle_not_found('', fqn, options)
end