line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Promises6::Builder; |
2
|
32
|
|
|
32
|
|
160901
|
use Evo -class, -modern; |
|
32
|
|
|
|
|
47
|
|
|
32
|
|
|
|
|
177
|
|
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
|
563
|
my $self = _instance(shift); |
31
|
268
|
|
|
|
|
484
|
$self->promise_class->new(@_, builder => $self); |
32
|
|
|
|
|
|
|
} |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
sub listener { |
35
|
158
|
|
|
158
|
1
|
967
|
my $self = _instance(shift); |
36
|
158
|
|
|
|
|
322
|
$self->listener_class->new(@_, builder => $self); |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub deferred { |
40
|
250
|
|
|
250
|
1
|
2841
|
my $self = _instance(shift); |
41
|
250
|
|
|
|
|
443
|
$self->deferred_class->new(@_, builder => $self); |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
|
45
|
184
|
50
|
|
184
|
1
|
489
|
sub singleton($class,@args) { |
|
184
|
|
|
|
|
202
|
|
|
184
|
|
|
|
|
615
|
|
|
184
|
|
|
|
|
199
|
|
46
|
184
|
|
33
|
|
|
708
|
state $single = (ref $class || $class)->new(@args); |
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
706
|
50
|
|
706
|
|
1138
|
sub _instance { ref $_[0] ? $_[0] : $_[0]->singleton } |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
1; |
52
|
|
|
|
|
|
|
|
53
|
|
|
|
|
|
|
# ABSTRACT: A builder for promises |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
__END__ |