File Coverage

blib/lib/Mojolicious/Plugin/RenderSteps.pm
Criterion Covered Total %
statement 17 17 100.0
branch 2 4 50.0
condition 1 2 50.0
subroutine 3 3 100.0
pod 1 1 100.0
total 24 27 88.8


line stmt bran cond sub pod time code
1             package Mojolicious::Plugin::RenderSteps;
2 1     1   571 use Mojo::Base 'Mojolicious::Plugin';
  1         2  
  1         5  
3              
4             our $VERSION = '0.06';
5              
6             sub register {
7 1     1 1 33 my ($self, $app) = @_;
8             $app->helper(
9             render_steps => sub {
10 2     2   19158 my ($self, @steps) = @_;
11 2         4 my $tx = $self->tx;
12 2         10 $self->render_later;
13 2         38 $self->stash->{'rendersteps.depth'}++;
14 2         20 my $delay = Mojo::IOLoop->delay(@steps);
15 2         219 $delay->on(error => sub { $self->helpers->reply->exception(pop) });
  1         366  
16             $delay->on(
17             finish => sub {
18 1         438 my $delay = shift;
19             $self->render_maybe
20             or $self->render_not_found
21 1 50 50     4 unless --$self->stash->{'rendersteps.depth'};
22 1         4356 undef $tx;
23             }
24 2         12 );
25 2 50       10 $delay->wait unless Mojo::IOLoop->is_running;
26             }
27 1         9 );
28             }
29              
30             1;
31             __END__