File Coverage

blib/lib/Object/Meta/Plugin/Useful/Greedy.pm
Criterion Covered Total %
statement 26 26 100.0
branch n/a
condition n/a
subroutine 7 7 100.0
pod 1 1 100.0
total 34 34 100.0


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2             # $Id: Greedy.pm,v 1.9 2003/12/10 03:52:30 nothingmuch Exp $
3              
4             package Object::Meta::Plugin::Useful::Greedy;
5              
6 1     1   1119 use strict;
  1         2  
  1         34  
7 1     1   4 use warnings;
  1         2  
  1         23  
8              
9 1     1   4 use base 'Object::Meta::Plugin::Useful';
  1         2  
  1         548  
10              
11 1     1   6 use Devel::Symdump;
  1         1  
  1         18  
12 1     1   941 use Class::ISA;
  1         2988  
  1         208  
13              
14             our $VERSION = 0.02;
15              
16             sub exports {
17 2     2 1 870 my $self = shift;
18 2         4 my %seen;
19            
20 25         55 return $self->_filter( # filters the method names
21 25         63 grep { not $seen{$_}++ } # filter duplicates
22 25         41 map { s/.*:://; $_ } # $_ is any function implemented somewhere in $self's @ISA tree. Removes the namespace of all the functions.
  9         1234  
23             map { Devel::Symdump->new($_)->functions() } # $_ is any package that $self is (-a). Returns all the functions in all the packages.
24             ($_, Class::ISA::super_path($_)) # $_ is the package of $self, because of the for right below here
25 2         13 ) for ref $self;
26             }
27              
28             sub _filter {
29 1     1   20 shift;
30 8         23 return grep { !/^(?:
  11         21  
31             croak | # imported into the namespace
32             carp |
33             exports | # provided by this class
34             init | # provided by the
35             new # typically undesired
36 1         3 )$/x } grep { /^(?!_)/ } @_;
37             }
38              
39             1; # Keep your mother happy.
40              
41             __END__