puppetlabs-stdlib/lib/puppet/parser/functions/getvar.rb
nfagerlund 4b5dfcc733 Docs: Copyedit function doc strings
This commit makes several minor consistency and wording edits to the doc
strings of the stdlib functions.
2011-08-18 12:39:04 -07:00

26 lines
660 B
Ruby

module Puppet::Parser::Functions
newfunction(:getvar, :type => :rvalue, :doc => <<-'ENDHEREDOC') do |args|
Lookup a variable in a remote namespace.
For example:
$foo = getvar('site::data::foo')
# Equivalent to $foo = $site::data::foo
This is useful if the namespace itself is stored in a string:
$datalocation = 'site::data'
$bar = getvar("${datalocation}::bar")
# Equivalent to $bar = $site::data::bar
ENDHEREDOC
unless args.length == 1
raise Puppet::ParseError, ("getvar(): wrong number of arguments (#{args.length}; must be 1)")
end
self.lookupvar("#{args[0]}")
end
end