Mojo/Steps.pm

filter: Statementstmt 35.1% 13 / 37 Branchbran 0.0% 0 / 10 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 27.2% 3 / 11 Podpod 0.0% 0 / 2 totaltotal 26.6% 16 / 60 CC 6 SCAR 20.8
CC
6
Cov
28%
_next
20.0
steps
12.0
__ANON__
2.0
CRAP 8.0
« Mojo.pm ↑ Summary
1 package JobCenter::Client::Mojo::Steps;
2  
3 1 ▶use Mojo::Base -base;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use Mojo::IOLoop;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 1 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 0 ▶has ioloop => sub { Mojo::IOLoop->singleton };
Subroutine __ANON__: not called CC=1 SCAR=1.2
9 0 ▶has _remaining => sub { [] };
Subroutine __ANON__: not called CC=1 SCAR=1.2
10 0 ▶has _errcb => sub { sub { say STDERR "caught >>> $_[0] <<<" } };
Subroutine __ANON__: not called CC=1 SCAR=2.6
11  
12 0 ▶sub steps {
Subroutine steps: not called CC=3 SCAR=24.8
Pod undocumented
13 0 my ($self, $cbs, $errcb, @args) = @_;
14 0 ▶ croak "no callbacks" unless ref $cbs eq 'ARRAY';
Branch: 1 branch
BranchTrueFalseTotal
unless ref $cbs eq "ARRAY" 0 0 0
15 # todo: check that array elements are coderefs
16 0 $self->_remaining($cbs);
17 0 ▶ $self->_errcb($errcb) if ref $errcb eq 'CODE';
Branch: 1 branch
BranchTrueFalseTotal
if ref $errcb eq "CODE" 0 0 0
18
19 0 ▶ $self->ioloop->next_tick(sub { $self->_next(@args) });
Subroutine __ANON__: not called CC=1 SCAR=6.9
20 0 return $self;
21 }
22  
23 0 ▶sub next {
Subroutine next: not called CC=1 SCAR=6.9
Pod undocumented
24 0 my ($self) = @_;
25 0 ▶ return sub { $self->_next(@_) };
Subroutine __ANON__: not called CC=1 SCAR=6.9
26 }
27  
28 0 ▶sub _next {
Subroutine _next: not called CC=4 SCAR=30.0
29 0 my $self = shift;
30 0 ▶ my $cb = shift @{$self->_remaining}
Branch: 1 branch
BranchTrueFalseTotal
my $cb = shift @{$self->_remaining;} or return 0 0 0
31 or return;
32 0 ▶ unless (eval { $cb->($self, @_); 1 }) {
Branch: 1 branch
BranchTrueFalseTotal
unless (eval { do { &$cb($self, @_); 1 } }) 0 0 0
33 0 my $e = $@;
34 0 eval { $self->_errcb->($e) };
35 0 ▶ warn $@ if $@;
Branch: 1 branch
BranchTrueFalseTotal
if $@ 0 0 0
36 }
37 }
38  
39 #sub DESTROY {
40 # say STDERR "destroying $_[0]";
41 #}
42  
43 1 1;
44  
45  
46 =encoding utf8
47  
48 =head1 NAME
49  
50 JobCenter::Client::Mojo::Steps - simplistic chained callbacks
51  
52 =cut
53  
« Mojo.pm ↑ Summary