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   966 use Mojo::Base 'Mojolicious::Plugin';
  1         2  
  1         6  
3              
4             our $VERSION = '0.05';
5              
6             sub register {
7 1     1 1 44 my ($self, $app) = @_;
8             $app->helper(
9             render_steps => sub {
10 2     2   59932 my ($self, @steps) = @_;
11 2         73 my $tx = $self->tx;
12 2         29 $self->render_later;
13 2         73 $self->stash->{'rendersteps.depth'}++;
14 2         46 my $delay = Mojo::IOLoop->delay(@steps);
15 2         692 $delay->on(error => sub { $self->render_exception(pop) });
  1         983  
16             $delay->on(
17             finish => sub {
18 1         1699 my $delay = shift;
19 1 50 50     4 $self->render_maybe
20             or $self->render_not_found
21             unless --$self->stash->{'rendersteps.depth'};
22 1         9342 undef $tx;
23             }
24 2         43 );
25 2 50       29 $delay->wait unless Mojo::IOLoop->is_running;
26             }
27 1         22 );
28             }
29              
30             1;
31             __END__