File Coverage

blib/lib/MooX/Pack.pm
Criterion Covered Total %
statement 44 45 97.7
branch 2 2 100.0
condition n/a
subroutine 11 12 91.6
pod n/a
total 57 59 96.6


line stmt bran cond sub pod time code
1             package MooX::Pack;
2              
3 3     3   471347 use strict;
  3         6  
  3         102  
4 3     3   26 use warnings;
  3         10  
  3         158  
5 3     3   17 use Carp qw/croak/;
  3         5  
  3         156  
6 3     3   2183 use MooX::ReturnModifiers;
  3         2119  
  3         416  
7              
8             our $VERSION = '0.04';
9              
10             sub import {
11 3     3   26 my ( $self, @import ) = @_;
12 3         11 my $target = caller;
13 3         27 my %modifiers = return_modifiers($target);
14 3     0   178 $modifiers{has}->( 'target' => ( is => 'ro', lazy => 1, default => sub { return $target; } ) );
  0         0  
15 3         79960 my ($spec, $aspec, $index) = ({}, undef, 0);
16 3     3   24 { no strict 'refs'; *{"${target}::line"} = sub {
  3         6  
  3         532  
  3         24  
17 12     12   53 my ( $name, %attributes ) = @_;
18 12 100       42 if (!$spec->{$name}) {
19 4         14 $spec->{$name}->{spec} = [];
20 4         10 $spec->{$name}->{index} = $index++;
21             }
22 12         17 push @{ $spec->{$name}->{spec} }, \%attributes;
  12         33  
23 3         18 }; }
24 3     3   16 { no strict 'refs'; *{"${target}::seperator"} = sub {
  3         5  
  3         591  
  3         7  
  3         5  
  3         35  
25 2     2   417 my ( %attributes ) = @_;
26 2         14 $aspec = \%attributes;
27 3         15 }; }
28 3         24 $modifiers{with}->('MooX::Pack::Base');
29             $modifiers{sub}->(
30             "_build_line_spec" => sub {
31 2     2   11 my ( $orig, $self ) = ( shift, shift );
32 2         28 return $spec;
33             }
34 3         3869 );
35             $modifiers{sub}->(
36             "_build_all_spec" => sub {
37 2     2   368960 my ( $orig, $self ) = ( shift, shift );
38 2         53 return $aspec;
39             }
40 3         48 );
41             }
42              
43             1;
44              
45             __END__