File Coverage

blib/lib/Object/Meta/Plugin/Useful/Generic.pm
Criterion Covered Total %
statement 23 24 95.8
branch 1 2 50.0
condition 2 7 28.5
subroutine 6 6 100.0
pod 2 3 66.6
total 34 42 80.9


line stmt bran cond sub pod time code
1             #!/usr/bin/perl
2             # $Id: Generic.pm,v 1.6 2003/12/10 03:52:30 nothingmuch Exp $
3              
4             package Object::Meta::Plugin::Useful::Generic; # an extended base class with some logical features $$$ ## rename to Usefull::Generic;
5              
6 1     1   3684 use strict;
  1         2  
  1         199  
7 1     1   5 use warnings;
  1         2  
  1         27  
8              
9 1     1   6 use base 'Object::Meta::Plugin::Useful';
  1         1  
  1         815  
10              
11             our $VERSION = 0.01;
12              
13             sub new {
14 1     1 0 371 my $pkg = shift;
15            
16 1         7 bless {
17             exports => [],
18             }, $pkg;
19             }
20              
21             sub export { # utility method: export a list of method names
22 1     1 1 24 my $self = shift;
23 1         4 my @try_export = @_;
24            
25 1         3 my %tested = map { $_, undef } @{ $self->{exports} };
  0         0  
  1         5  
26            
27 1 50 0     4 push @{ $self->{exports} }, grep {
  3   50     60  
      33        
28 1         3 (not exists $tested{$_}) and $tested{$_} = 1 # make sure we didn't pass this one already
29             and $self->can($_) or (warnings::warnif($self,"Export of undefined method $_ attempted") and undef); # make sure we can use the method. UNIVERSAL::can should be replaced if magic is going on. To shut it up, 'no warnings Plugin::Class'.
30             } @try_export;
31            
32 1         2 @{ $self->{exports} }; # number on scalar, list on list
  1         6  
33             }
34              
35             sub exports {
36 1     1 1 25 my $self = shift;
37 1         2 @{ $self->{exports} };
  1         10  
38             }
39              
40             1; # Keep your mother happy.
41              
42             __END__