Class::Can - inspect a class/method and say what it can do (and why)


Class-Can documentation Contained in the Class-Can distribution.

Index


Code Index:

NAME

Top

Class::Can - inspect a class/method and say what it can do (and why)

SYNOPSIS

Top

  use Class::Can;
  print Dumper { Class::Can->interrogate( 'Class::Can' ) };
  __END__
  $VAR1 = {
            'interrogate' => 'Class::Can'
  };

DESCRIPTION

Top

Class::Can interrogates the object heirarchy of a package to return a hash detailling what methods the class could dispatch (as the key), and the package it found it in (as the value).

AUTHOR

Top

Richard Clamp <richardc@unixbeard.net>

COPYRIGHT

Top

SEE ALSO

Top

Class::ISA, Devel::Symdump


Class-Can documentation Contained in the Class-Can distribution.
package Class::Can;
use strict;
use warnings;
use Class::ISA;
use Devel::Symdump;
our $VERSION = 0.01;

sub interrogate {
    my ($self, $class) = @_;
    my %can;
    for my $package (reverse Class::ISA::self_and_super_path( $class )) {
        my @methods = Devel::Symdump->new( $package )->functions;
        s{.*::}{} for @methods;
        @can{ @methods } = ($package) x @methods;
    }
    return %can;
}

1;