You have a defined type and want to use a default value for a parameter from a params class.
Set the default value of the variable as undef
, then put a conditional after including the params class in the class body in which you set another internal variable with the value of the params class variable or the user-defined value.
The most elegant way to do this would be to directly reference the variable as the default value of the parameter, such as in:
define test ( $myparam = $test::params::myparam ) {
include test::params
...
This, however, won't work unless you include the test::params
class in a higher scope.
Code for the defined type tend to grow quite a bit with the number of parameters. Also, since parameters cannot be reassigned, one is forced to introduce a new local variable; this worsen code readability and introduce a problem of clashing names.