File Coverage

blib/lib/Attribute/Constructor.pm
Criterion Covered Total %
statement 27 27 100.0
branch n/a
condition 2 3 66.6
subroutine 8 8 100.0
pod 0 1 0.0
total 37 39 94.8


line stmt bran cond sub pod time code
1             package Attribute::Constructor;
2              
3 1     1   11002 use 5.006;
  1         4  
  1         45  
4 1     1   5 use strict;
  1         2  
  1         39  
5 1     1   5 use warnings;
  1         8  
  1         40  
6              
7 1     1   2199 use Attribute::Handlers;
  1         16659  
  1         7  
8              
9             our $VERSION = '0.04';
10              
11             sub UNIVERSAL::Constructor : ATTR(CODE) {
12 1     1 0 2787 my ($package, $symbol, $referent, $attr, $data) = @_;
13              
14 1     1   88 no warnings 'redefine';
  1         3  
  1         203  
15 1         6 *{$symbol} = sub {
16              
17 2     2   227 my $self = shift;
18 2   66     11 my $class = ref($self) || $self;
19 2         4 my $instance = {};
20 2         4 bless( $instance, $class );
21              
22             # Run the constructor
23 2         5 $referent->( $instance, @_ );
24              
25             # Return the new object
26 2         17 return $instance;
27             }
28 1     1   6 }
  1         3  
  1         6  
  1         8  
29              
30             1;
31             __END__