Re: abstract search count
[prev]
[thread]
[next]
[Date index for 2004/06/17]
On Jun 17, 2004, at 9:01 AM, Tony Bowden wrote:
> On Wed, Jun 16, 2004 at 04:45:45PM +0200, Jean-Christophe Zeus wrote:
>> Seems like no one is interested in our efforts. :-(
>
> I find it interesting...
Well, it's :-) then! Sorry for the self pity...
>> What about one abstract plugin (i.e. without any methods) that all the
>> others inherit from, thereby making writing plugins easier? I will
>> think this through, and if it really makes sense, I'll do it.
>
> I've also considered writing this. What would you expect it to do?
Well, first of all, I think that removing the symbol table hackery
would be a good thing. My proposal is: all the plugin methods (not
starting with an underscore) are injected into the caller's package
automatically. Here's a prototype:
package Class::DBI::Plugin;
sub import
{
my $class = shift;
my $caller = caller;
no strict 'refs';
for my $symname ( keys %{ "$class\::" } ) {
local *sym = ${ "$class\::" }{ $symname };
*{ "$caller\::$symname" } = \&sym
if defined( &sym )
and substr( $symname, 0, 1 ) ne '_';
}
}
package Class::DBI::Plugin::SubClass;
use base 'Class::DBI::Plugin';
sub foo { print "inside foo()\n" }
sub bar { print "inside bar()\n" }
sub _baz { print "inside _baz()\n" }
# In a class inheriting form Class::DBI...
package Test;
use Class::DBI::Plugin::SubClass;
package main;
Test::foo();
Test::bar();
Test::_baz(); # fails
__END__
Next, I want to figure out how to inject the SQL etc.
What do you think?
--
J.-C Zeus (mail@xxxxxx.xxx)
|
(message missing)
|