File Coverage

blib/lib/Promises6/Builder.pm
Criterion Covered Total %
statement 15 15 100.0
branch 2 4 50.0
condition 1 3 33.3
subroutine 6 6 100.0
pod 4 4 100.0
total 28 32 87.5


line stmt bran cond sub pod time code
1             package Promises6::Builder;
2 33     33   22952 use Evo::Base -base;
  33         45  
  33         276  
3              
4             has promise_class => sub { require Promises6::Promise; 'Promises6::Promise'; };
5              
6             has listener_class =>
7             sub { require Promises6::Listener; 'Promises6::Listener'; };
8              
9             has deferred_class =>
10             sub { require Promises6::Deferred; 'Promises6::Deferred'; };
11              
12              
13             has resolver => sub {
14             my $self = _instance(shift);
15             require Promises6::Resolver;
16             Promises6::Resolver->new(@_, builder => $self);
17             };
18              
19             # commented 08.02.2015
20             #don't know if someone will use it other way
21             #has resolver_class =>
22             # sub { require Promises6::Resolver; 'Promises6::Resolver'; };
23             #
24             #sub resolver {
25             # my $self = _instance(shift);
26             # $self->resolver_class->new(@_, builder => $self);
27             #}
28              
29             sub promise {
30 268     268 1 2041 my $self = _instance(shift);
31 268         4372 $self->promise_class->new(@_, builder => $self);
32             }
33              
34             sub listener {
35 158     158 1 1834 my $self = _instance(shift);
36 158         2559 $self->listener_class->new(@_, builder => $self);
37             }
38              
39             sub deferred {
40 250     250 1 4627 my $self = _instance(shift);
41 250         4685 $self->deferred_class->new(@_, builder => $self);
42             }
43              
44              
45 184 50   184 1 468 sub singleton($class,@args) {
  184         233  
  184         432  
  184         183  
46 184   33     2131 state $single = (ref $class || $class)->new(@args);
47             }
48              
49 706 50   706   1512 sub _instance { ref $_[0] ? $_[0] : $_[0]->singleton }
50              
51             1;
52              
53             # ABSTRACT: A builder for promises
54              
55             __END__