On Wednesday, September 3, 2014 9:05:20 AM UTC-5, Atom Powers wrote:
>
> You may need to define local versions of them that equal the param or 
> default to the param.
>
> $var = $::class::params::var
>
>

Note that the point of the pattern of inheriting params classes is only to 
ensure that the inherited class is evaluated before the inheriting class, 
so that you can rely on the variables in question to have been defined in 
time for use as parameter defaults for the inheriting class.  There is no 
other good reason to use it.

In particular, it is poor form to inherit a class for the purpose of 
referring to its variables via unqualified names; you should *always* refer 
to the variables of any other class via their qualified names, even if the 
current class inherits from the variables' host class.

Also, where you don't need your params class for class parameter defaults, 
you should 'include' it instead of inheriting from it.

If you want a local version of a(nother) class's variable (maybe for 
conveniece with templates) then you should create one in exactly the way AP 
described (but don't forget to 'include' the params class).  For most 
purposes, however, you can just refer to the foreign variable via its 
qualified name.


John

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to puppet-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/fb58f0cb-ed24-4830-8fb1-e2a84778bbca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to