Class::DBI::Plugin
[prev]
[thread]
[next]
[Date index for 2004/06/30]
In the thread "abstract search count" I volunteered writing an abstract
base class for cdbi plugins. The reason for this is to make writing
plugins easier, i.e. no symbol table hackery and no (well, no too much)
knowledge about the internals of Class::DBI.
In the thread mentioned above, Stephen Quinney proposed using code
attributes to specify which methods of the plugin subclass should be
"plugged" in the caller's package.
My proposals are as follows:
1) Methods with the attribute "Plugged" are exported,
2) The optional constant SQL is used for setting SQL in the caller's
package.
Here is an example (abridged):
package Class::DBI::Plugin::AbstractCount;
use base 'Class::DBI::Plugin';
use constant SQL => ( count_search_where => $SQL );
sub count_search_where : Plugged
{
my $class = shift;
# ...
$class->sql_count_search_where( ... );
}
I refactored the original version of this plugin (which didn't inherit
from Class::DBI::Plugin), and that cleaned it up a lot.
Of course there are lots of features which could be added, but I think
it's already quite useful, so I will upload it to CPAN. Is it OK for
everyone if I use this name? Any comments on the interface?
--
J.-C Zeus (mail@xxxxxx.xxx)
|
Class::DBI::Plugin
Jean-Christophe Zeus 15:38 on 30 Jun 2004
|