I've extended lookup_method to support sub-classed objects. which simplifies the usage. It's now committed. Here is a test:

perl -MModPerl::MethodLookup -le '\
package Apache::RequestRec; sub new { bless {}, shift }; \
package My::Request; @ISA = qw(Apache::RequestRec); \
package main; my $obj = My::Request->new();  \
my($hint, @modules) = ModPerl::MethodLookup::lookup_method("print", $obj); \
print $hint'
To use method 'print' add:
        use Apache::RequestIO ();

So EazyLife.pm, including fixes for your previous comments, looks like:

package ModPerl::EazyLife;

use ModPerl::MethodLookup ();
use Carp;

my @avail_modules = ModPerl::MethodLookup::avail_modules();
push @avail_modules, 'Apache'; # XXX: may go away
my $skip = qr|(::)?DESTROY$|;
for my $module (@avail_modules) {
    *{"$module\::AUTOLOAD"} = sub {
        my($hint, @modules) =
            ModPerl::MethodLookup::lookup_method($AUTOLOAD, @_);

        if (@modules) {
            eval "require $_" for @modules;
            goto &$AUTOLOAD;
        }
        else {
            return if $AUTOLOAD =~ /$skip/;
            croak $hint || "Can't find $AUTOLOAD";
        }
    };
}

1;

You need to update your cvs and rebuild (because of the changes in the autogenerated MethodLookup.pm module).

__________________________________________________________________
Stas Bekman            JAm_pH ------> Just Another mod_perl Hacker
http://stason.org/     mod_perl Guide ---> http://perl.apache.org
mailto:[EMAIL PROTECTED] http://use.perl.org http://apacheweek.com
http://modperlbook.org http://apache.org   http://ticketmaster.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to