in reply to Creating dynamic parent/child relationships
Don't use inheritance for this.
Consider having an array of "modificators" or "plugins" (for lack of detail) that the main class calls:
my $foo = One->new_from_config('myconfig.yml'); print Dumper $foo->frobnicate($bar); sub One::frobnicate( $self, $item ) { for my $step (@{ $self->steps }) { $item = $step->frobnicate( $item ); }; return $item }
The One::frobnicate method dispatches the call to all the listed ->frobnicate methods in ->steps. The ->steps array is filled with classes (or instances) from the configuration.
See also Module::Pluggable, which can load plugins.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Creating dynamic parent/child relationships
by nysus (Parson) on Sep 03, 2019 at 17:14 UTC | |
|
Re^2: Creating dynamic parent/child relationships
by nysus (Parson) on Sep 03, 2019 at 17:34 UTC | |
by nysus (Parson) on Sep 03, 2019 at 18:35 UTC |