Sub-Methodical
view release on metacpan or search on metacpan
Makefile.PL view on Meta::CPAN
use inc::Module::Install;
name 'Sub-Methodical';
all_from 'lib/Sub/Methodical.pm';
author 'Hans Dieter Pearcey <hdp@cpan.org>';
build_requires 'Test::More';
requires 'PadWalker';
requires 'Filter::EOF';
requires 'Sub::Exporter';
requires 'Sub::Install';
auto_install;
WriteAll;
lib/Sub/Methodical.pm view on Meta::CPAN
package Sub::Methodical;
our $VERSION = '0.002';
my %methodical;
my %wrapped;
my %auto_methodical;
use B;
use PadWalker;
use Filter::EOF;
use Sub::Install ();
use Sub::Exporter -setup => {
exports => [
MODIFY_CODE_ATTRIBUTES => \&_build_MODIFY,
AUTOLOAD => \&_build_AUTOLOAD,
],
groups => {
default => [qw(MODIFY_CODE_ATTRIBUTES)],
inherit => [qw(AUTOLOAD)],
lib/Sub/Methodical.pm view on Meta::CPAN
#warn "wrapping $name ($pkg\::$as)\n";
$wrapped{$pkg}{$as} = $sub;
Sub::Install::reinstall_sub({
into => $pkg,
as => $as,
code => sub {
if (eval { $_[0]->isa($pkg) }) {
#warn "calling $name directly: @_\n";
return $sub->(@_);
}
my $pad = PadWalker::peek_my(1);
my $self = $pad->{'$self'};
unless ($self) {
die "can't find \$self!";
}
unless (eval { $$self->isa($pkg) }) {
require Carp;
Carp::croak sprintf
"Methodical '%s' called with incorrect invocant '%s' (wanted '%s')",
$as, $$self, $pkg;
}
( run in 0.573 second using v1.01-cache-2.11-cpan-05444aca049 )