File Coverage

blib/lib/MooX/Keyword/Factory.pm
Criterion Covered Total %
statement 25 25 100.0
branch 4 4 100.0
condition n/a
subroutine 6 6 100.0
pod n/a
total 35 35 100.0


line stmt bran cond sub pod time code
1             package MooX::Keyword::Factory;
2              
3 2     2   465715 use 5.006; use strict; use warnings; our $VERSION = '1.01';
  2     2   7  
  2     2   14  
  2         3  
  2         63  
  2         10  
  2         4  
  2         186  
4 2     2   1091 use Factory::Sub; use Moo;
  2     2   223631  
  2         10  
  2         761  
  2         8726  
  2         14  
5              
6             our %FACTORY;
7              
8             use MooX::Keyword {
9             factory => {
10             builder => sub {
11 2         172851 my ($moo, $name, @args) = @_;
12 2 100       14 if (! $FACTORY{$name}) {
13 1         45 $moo->has($name, is => 'rw');
14             $moo->around($name, sub {
15 3         9158 my ($orig, $self, @args) = @_;
16 3 100       62 $self->$orig(scalar @args ? $FACTORY{$name}->(@args) : ());
17 1         33279 });
18 1         5942 $FACTORY{$name} = Factory::Sub->new();
19             }
20 2         28 $FACTORY{$name}->add(@args);
21             }
22             }
23 2     2   3185 };
  2         23372  
  2         29  
24              
25             1;
26              
27             __END__