File Coverage

blib/lib/EO/Attributes.pm
Criterion Covered Total %
statement 45 72 62.5
branch 0 4 0.0
condition n/a
subroutine 14 19 73.6
pod 0 3 0.0
total 59 98 60.2


line stmt bran cond sub pod time code
1              
2             package EO::Attributes;
3              
4 18     18   96 use strict;
  18         32  
  18         582  
5 18     18   93 use warnings;
  18         44  
  18         735  
6              
7 18     18   19361 use Attribute::Handlers;
  18         123642  
  18         129  
8 18     18   730 use Scalar::Util qw(blessed);
  18         41  
  18         4266  
9              
10             our $VERSION = 0.96;
11              
12             sub UNIVERSAL::Private : ATTR(CODE) {
13 0     0 0 0 my ($package, $symbol, $referent, $attr, $data) = @_;
14 18     18   97 no strict 'refs';
  18         41  
  18         480  
15 18     18   90 no warnings 'redefine';
  18         33  
  18         3302  
16 0         0 my $thing = *{$symbol};
  0         0  
17 0         0 my $meth = substr($thing, rindex($thing,':')+1);
18 0         0 *{$symbol} = sub {
19 0     0   0 my $self = shift;
20 0         0 my $class = ref($self);
21 0         0 my ($callpkg, $callfile, $callline) = caller();
22 0 0       0 if ($package ne $callpkg) {
23 0         0 my $text = "Can't private method \"$meth\" from package $package";
24 0         0 throw EO::Error::Method::Private
25             text => $text,
26             file => $callfile;
27             }
28 0         0 $referent->( $self, @_ );
29 0         0 };
30 18     18   486 }
  18         36  
  18         95  
31              
32              
33             sub UNIVERSAL::Abstract : ATTR(CODE) {
34 1     1 0 3019 my ($package, $symbol, $referent, $attr, $data) = @_;
35 18     18   20356 no strict 'refs';
  18         47  
  18         621  
36 18     18   97 no warnings 'redefine';
  18         33  
  18         5602  
37 1         2 my $thing = *{$symbol};
  1         2  
38 1         6 my $meth = substr($thing, rindex($thing,':')+1);
39 1         4 *{$symbol} = sub {
40 0     0   0 my $self = shift;
41 0 0       0 my $class = blessed($self) ? ref($self) : $self;
42 0         0 my ($package, $filename, $line) = caller();
43 0         0 my $text = "Can't call abstract method \"$meth\" on object of type \"$class\"";
44 0         0 throw EO::Error::Method::Abstract
45             text => $text,
46             file => $filename;
47 1         6 };
48 18     18   107 }
  18         70  
  18         110  
49              
50             sub UNIVERSAL::Deprecated : ATTR(CODE) {
51 0     0 0   my ($package, $symbol, $referent, $attr, $data) = @_;
52 18     18   5111 no strict 'refs';
  18         36  
  18         548  
53 18     18   95 no warnings 'redefine';
  18         86  
  18         2640  
54 0           my $thing = *{$symbol};
  0            
55 0           my $meth = substr($thing, rindex($thing,':')+1);
56 0           *{$symbol} = sub {
57 0     0     my ($pkg, $filename, $line) = caller();
58 0           print STDERR "use of deprecated method $meth at $filename line $line\n";
59 0           $referent->( @_ );
60             }
61 18     18   92 }
  18         72  
  18         87  
  0            
62              
63             #sub UNIVERSAL::private : ATTR(CODE) { UNIVERSAL::Private(@_) }
64             #sub UNIVERSAL::abstract : ATTR(CODE) { UNIVERSAL::Private(@_) }
65              
66             1;
67              
68             __END__