in reply to Re: Plugin Overwriting or saving keys in Algorithm::CheckDigits configuration
in thread Plugin Overwriting or saving keys in Algorithm::CheckDigits configuration
My idea is something more complex along the line first one wins, second one gets renamed.
I think that any module that is already registered under a key should be available with that key while the program is running. And any module wanting to be registered should be registered. This implies that there may be cases when two modules want to be registered with the same key (think of two plugins by different authors). In that case I would register it with another key. To use the second module, the program has to know the new key. Thats why plug_in() should return the real key under which it registered the module.
The interface could be like this for plugin modules:
package MyPluginLibA; use Algorithm::CheckDigits; our @EXPORT = qw( CheckDigits ); our @ISA = qw(Algorithm::CheckDigits); our $method = Algorithm::CheckDigits::plug_in('mpla','MyPluginLibA');
Inheritance and reexport of CheckDigits() is just for convenient use of the plugin module. So the user of the plugin module does not need to use Algorithm::CheckDigits; but can use the interface.
And then it looks like this for the user of the plugin module:
use MyPluginLibA; my $cd = CheckDigits($MyPluginLibA::method);
Algorithm::CheckDigits::plug_in() would only get two arguments, the key and the module name. If the key is already in use, it would find another key to add the module name and return that other key.
If there is a module that behaves differently for variations of the key (like the module that computes check digits for VISA, AMEX, ISIN, IMEI, ...) it would have to provide a mapping between the intended key and the one returned by Algorithm::CheckDigits::plug_in(). And it should clearly document how to access the different keys.
Would that be too complex?
Update: tried to make my intention more clear
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Plugin Overwriting or saving keys in Algorithm::CheckDigits configuration
by MidLifeXis (Monsignor) on Apr 21, 2013 at 18:28 UTC | |
by mamawe (Sexton) on Apr 21, 2013 at 21:30 UTC |