Promises/Sub.pm

filter: Statementstmt 100% 37 / 37 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 13 / 13 Podpod 0.0% 0 / 2 totaltotal 94.4% 51 / 54 CC 2 SCAR 1.3
CC
2
Cov
97%
Defer
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Promises/Promise.pm ↑ Summary
1 package Promises::Sub;
2 2 our $AUTHORITY = 'cpan:YANICK';
3 # ABSTRACT: Turns functions into promises
4 2 $Promises::Sub::VERSION = '1.05';
5 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 2 ▶use Sub::Attribute;
Subroutine BEGIN: called CC=1 SCAR=0.0
9 2 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 2 ▶use Promises qw/ collect /;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 2 ▶use parent 'Exporter';
Subroutine BEGIN: called CC=1 SCAR=0.0
14  
15 2 our @EXPORT_OK = qw/ defer /;
16  
17 2 ▶sub defer(&) {
Subroutine defer: called CC=1 SCAR=0.0
Pod undocumented
18 2 my $coderef = shift;
19  
20 4 ▶ return sub {
Subroutine __ANON__: called CC=1 SCAR=0.0
21 4 ▶ collect( @_ )->then( sub { $coderef->( map { @$_ } @_ ) } );
Subroutine __ANON__: called CC=1 SCAR=0.0
22 }
23  
24 2 }
25  
26 1 ▶sub Defer :ATTR_SUB {
Subroutine Defer: called CC=2 SCAR=7.0
Pod undocumented
27 1 my( undef, $symbol, $referent ) = @_;
28  
29 1 ▶ croak "can't use attribute :Defer on an anonynous sub, use 'defer' instead"
Branch: 1 branch
BranchTrueFalseTotal
unless $symbol 0 1 1
30 unless $symbol;
31  
32 2 ▶ no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
33 1 ▶ $$symbol = defer { $referent->(@_) };
Subroutine __ANON__: called CC=1 SCAR=0.0
34 2 ▶}
Subroutine BEGIN: called CC=1 SCAR=0.0
35  
36  
37 2 1;
38  
39 __END__
« Promises/Promise.pm ↑ Summary