File Coverage

blib/lib/Action/Retry/Strategy/HelperRole/SleepTimeout.pm
Criterion Covered Total %
statement 3 3 100.0
branch n/a
condition n/a
subroutine 1 1 100.0
pod n/a
total 4 4 100.0


line stmt bran cond sub pod time code
1             #
2             # This file is part of Action-Retry
3             #
4             # This software is copyright (c) 2013 by Damien "dams" Krotkine.
5             #
6             # This is free software; you can redistribute it and/or modify it under
7             # the same terms as the Perl 5 programming language system itself.
8             #
9             package Action::Retry::Strategy::HelperRole::SleepTimeout;
10             {
11             $Action::Retry::Strategy::HelperRole::SleepTimeout::VERSION = '0.24';
12             }
13              
14             # ABSTRACT: Helper to be consumed by Action::Retry Strategies, to enable giving up retrying when the sleep_time is too big
15              
16 4     4   4950 use Moo::Role;
  4         10  
  4         29  
17              
18             has max_sleep_time => (
19             is => 'ro',
20             lazy => 1,
21             default => sub { undef },
22             );
23              
24             around needs_to_retry => sub {
25             my $orig = shift;
26             my $self = shift;
27             defined $self->max_sleep_time
28             or return $orig->($self, @_);
29             $orig->($self, @_) && $self->compute_sleep_time < $self->max_sleep_time
30             };
31              
32             1;
33              
34             __END__