Hi Monks!
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):
package base; my %cfg=( on_error => "exit", output_type => "text", ); sub new { ..blah blah.. do_something if ($cfg{on_error} eq 'exit'); } package child; use parent "base"; my %cfg=( on_error => "warn", ); sub new {...}
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!
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |