File Coverage

blib/lib/ex/interface.pm
Criterion Covered Total %
statement 14 26 53.8
branch 0 4 0.0
condition n/a
subroutine 3 5 60.0
pod 0 1 0.0
total 17 36 47.2


line stmt bran cond sub pod time code
1             package ex::interface;
2              
3 4     4   2500 use strict;
  4         7  
  4         147  
4 4     4   22 no strict 'refs';
  4         6  
  4         1332  
5              
6             require 5.6.0;
7             our $VERSION = "0.2";
8              
9              
10             sub import {
11 4     4   29 my $self = shift;
12 4         12 my %__METHOD = map {$_ => 1} @_;
  12         38  
13 4         12 my $interface = caller;
14 4         6 *{"$interface\::__METHOD"} = \%__METHOD;
  4         24  
15 4         10 *{"$interface\::AUTOLOAD"} = \&their_AUTOLOAD;
  4         1944  
16             }
17              
18             sub their_AUTOLOAD {
19 0     0 0   our $AUTOLOAD = $AUTOLOAD;
20 0           $AUTOLOAD =~ s/(.*):://;
21 0 0         return if $AUTOLOAD eq 'DESTROY';
22 0           my $interface = $1;
23 0 0         if ($ {"$interface\::__METHOD"}{$AUTOLOAD}) {
  0            
24 0           require Carp;
25 0           Carp::croak("The interface method '$AUTOLOAD' has not been implemented");
26             }
27             else {
28 0           my $self = shift;
29 0           $AUTOLOAD =~ s/^/SUPER::/;
30 0           $self->$AUTOLOAD(@_);
31             }
32             }
33              
34 0     0     sub DESTROY { return }
35              
36             1;