| 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 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | ▶ | use base 'Object::Meta::Plugin::Useful'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | 1 | ▶ | use Devel::Symdump; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 12 | 1 | ▶ | use Class::ISA; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | |||
| 14 | 1 | our $VERSION = 0.02; | |
| 15 | |||
| 16 | 2 | ▶ | sub exports { |
|
Subroutine
exports: called CC=2 SCAR=6.9
Pod
documented
| |||
| 17 | 2 | my $self = shift; | |
| 18 | 2 | my %seen; | |
| 19 | |||
| 20 | return $self->_filter( # filters the method names | ||
| 21 | 25 | grep { not $seen{$_}++ } # filter duplicates | |
| 22 | 25 | map { s/.*:://; $_ } # $_ is any function implemented somewhere in $self's @ISA tree. Removes the namespace of all the functions. | |
| 23 | 9 | 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 | ) for ref $self; | |
| 26 | } | ||
| 27 | |||
| 28 | 1 | ▶ | sub _filter { |
|
Subroutine
_filter: called CC=1 SCAR=0.0
| |||
| 29 | 1 | shift; | |
| 30 | 8 | return grep { !/^(?: | |
| 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 | )$/x } grep { /^(?!_)/ } @_; | |
| 37 | } | ||
| 38 | |||
| 39 | 1 | 1; # Keep your mother happy. | |
| 40 | |||
| 41 | __END__ | ||