|Perl: the Markov chain saw|
Inheritable configuration options.... but with default values?by Amblikai (Scribe)
|on Feb 20, 2020 at 16:57 UTC||Need Help??|
Amblikai has asked for the wisdom of the Perl Monks concerning the following question:
I'm racking my brain with this one and can't seem to find an elegant solution. I hope you can help!
Basically i have a series of classes and subclasses, each level adding a bit more functionality to its parent and in each class i have behaviour which can be modified by configuration options which are specific to that class
All pretty straight forward so far. I can have a class method which sets the values of a hash which can be accessed by each object.
However, how do i have default values for my configuration options (written into the class)? Which can be added to in each subsequent class?
For example (Pseudo Code):
Where in the above example, the child class has the default value for "output_type" inherited from the parent class, but can change configuration options too
I've set off in the direction of having a config class singleton which is instantiated (referenced) from within the child classes but i can't fathom how to give it default values in the manner above
Thanks in advance for any help!