File Coverage

blib/lib/Tak/Request.pm
Criterion Covered Total %
statement 6 19 31.5
branch 0 2 0.0
condition n/a
subroutine 2 9 22.2
pod 0 7 0.0
total 8 37 21.6


line stmt bran cond sub pod time code
1             package Tak::Request;
2              
3 1     1   474 use Tak::Result;
  1         3  
  1         35  
4 1     1   8 use Moo;
  1         2  
  1         4  
5              
6             has on_progress => (is => 'ro');
7              
8             has on_result => (is => 'ro', required => 1);
9              
10             has is_done => (is => 'rw', default => sub { 0 });
11              
12             sub progress {
13 0     0 0   my ($self, @report) = @_;
14 0 0         if (my $cb = $self->on_progress) {
15 0           $cb->(@report);
16             }
17             }
18              
19             sub result {
20 0     0 0   my ($self, $type, @data) = @_;
21 0           $self->is_done(1);
22 0           $self->on_result->(Tak::Result->new(type => $type, data => \@data));
23             }
24              
25             sub flatten {
26 0     0 0   my ($self) = @_;
27 0           return ($self->type, @{$self->data});
  0            
28             }
29              
30 0     0 0   sub success { shift->result(success => @_) }
31 0     0 0   sub mistake { shift->result(mistake => @_) }
32 0     0 0   sub failure { shift->result(failure => @_) }
33 0     0 0   sub fatal { shift->result(fatal => @_) }
34              
35             1;