Skip to content

Instantly share code, notes, and snippets.

@zaphod42
Created February 25, 2013 20:27
Show Gist options
  • Select an option

  • Save zaphod42/5032998 to your computer and use it in GitHub Desktop.

Select an option

Save zaphod42/5032998 to your computer and use it in GitHub Desktop.
def lookupvar(name, options = {})
unless name.is_a? String
raise Puppet::DevError, "Scope variable name is a #{name.class}, not a string"
end
table = ephemeral?(name) ? @ephemeral.last : @symtable
if name =~ /^(.*)::(.+)$/
class_name = $1
variable_name = $2
lookup_qualified_variable(class_name, variable_name, options)
elsif table.include?(name)
table[name]
else
next_scope = inherited_class_scope || enclosing_scope
if next_scope
next_scope.lookupvar(name, options)
else
nil
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment