summaryrefslogtreecommitdiffstats
path: root/lib/puppet/reference/function.rb
diff options
context:
space:
mode:
authorMarkus Roberts <Markus@reality.com>2010-10-21 17:24:09 -0700
committerNick Lewis <nick@puppetlabs.com>2011-04-12 12:47:31 -0700
commit31f8e660c8f4c0ec01f140322cf7c585144a0888 (patch)
tree115f2b3d2b31c005b4b0de81b74d9195fa6ca495 /lib/puppet/reference/function.rb
parentd5dc3036eda210f318160e2442f7b65e0995ee23 (diff)
downloadpuppet-31f8e660c8f4c0ec01f140322cf7c585144a0888.tar.gz
puppet-31f8e660c8f4c0ec01f140322cf7c585144a0888.tar.xz
puppet-31f8e660c8f4c0ec01f140322cf7c585144a0888.zip
Refactor en route to #5027 -- remove usestring parameter from lookupvar
The usestring parameter to lookupvar was objectionable for several reasons; first, it performed a function orthogonal to the main purpose of the method, second its default was the least common value, and third it was causing other code to work for reasons that were not obvious (extlookup). This refactor breaks the value-transforming function out into a seperate method which allows the user to specify the value to be used in lieu of :undef and removes the parameter. The function, Scope#undef_as(default,exp) is written so that it can be used in user code (templates, functions, etc.) if needed. This refactor will introduce a user-visible behaviour change in the case where users were counting on lookupvar to return "" for undefined variables. The best solution is to have them use undef_as, replacing: lookupvar('myvar') with undef_as('',lookupvar('myvar')) (with the option to specify another default value if desired). If this is too objectionable, we could rename the existing lookupvar as raw_lookupvar and define def lookupvar(v) undef_as('',raw_lookupvar(v)) end to restore the present behaviour.
Diffstat (limited to 'lib/puppet/reference/function.rb')
0 files changed, 0 insertions, 0 deletions