blib/lib/Plack/Middleware/Refresh.pm untested

filter: Statementstmt 0.0% 0 / 22 Branchbran 0.0% 0 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 6 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 34 CC 3 SCAR 13.9
CC
3
Cov
0%
prepare_app
6.0
call
6.0
BEGIN
2.0
CRAP 4.0
1 package Plack::Middleware::Refresh;
2 use strict;
3 use parent qw(Plack::Middleware);
4 use Module::Refresh;
5 use Plack::Util::Accessor qw(last cooldown);
6  
7 sub prepare_app {
8 my $self = shift;
9 $self->cooldown(10) unless defined $self->cooldown;
10  
11 Module::Refresh->new;
12 $self->last(time - $self->cooldown);
13 }
14  
15 sub call {
16 my($self, $env) = @_;
17  
18 if (time > $self->last + $self->cooldown) {
19 Module::Refresh->refresh;
20 $self->last(time);
21 }
22  
23 $self->app->($env);
24 }
25  
26 1;
27  
28 __END__