File Coverage

blib/lib/MooX/Keyword/Chain.pm
Criterion Covered Total %
statement 24 24 100.0
branch 5 6 83.3
condition n/a
subroutine 5 5 100.0
pod n/a
total 34 35 97.1


line stmt bran cond sub pod time code
1             package MooX::Keyword::Chain;
2 2     2   488279 use 5.006; use strict; use warnings;
  2     2   8  
  2     2   11  
  2         3  
  2         65  
  2         9  
  2         5  
  2         141  
3             our $VERSION = '1.01';
4 2     2   832 use Moo; our %CHAINS;
  2         10825  
  2         11  
5             use MooX::Keyword {
6             chain => {
7             builder => sub {
8 3         218613 my ($moo, $name, $chain, $cb) = @_;
9 3 100       76 $moo->has($name, is => 'rw') if ! $CHAINS{$name}++;
10 3         504 $moo->sub($chain, $cb);
11             $moo->around($name, sub {
12 3         1929 my ($orig, $self, @args) = @_;
13 3         57 @args = $self->$orig(@args);
14 3         7 @args = eval {
15 3         9 $cb->($self, @args);
16             };
17 3 50       24 die "${chain}: $@" if ($@);
18 3 100       12 return wantarray ? @args : shift @args;
19 3         134 });
20             }
21             }
22 2     2   3379 };
  2         20976  
  2         27  
23              
24             1;
25              
26             __END__