File Coverage

blib/lib/Email/Sender/Failure/Multi.pm
Criterion Covered Total %
statement 23 29 79.3
branch 6 12 50.0
condition 3 3 100.0
subroutine 7 7 100.0
pod 3 3 100.0
total 42 54 77.7


line stmt bran cond sub pod time code
1             package Email::Sender::Failure::Multi 1.500;
2             # ABSTRACT: an aggregate of multiple failures
3              
4 6     6   470 use Moo;
  6         11  
  6         29  
5             extends 'Email::Sender::Failure';
6              
7 6     6   2161 use MooX::Types::MooseLike::Base qw(ArrayRef);
  6         5653  
  6         1945  
8              
9             #pod =head1 DESCRIPTION
10             #pod
11             #pod A multiple failure report is raised when more than one failure is encountered
12             #pod when sending a single message, or when mixed states were encountered.
13             #pod
14             #pod =attr failures
15             #pod
16             #pod This method returns a list of other Email::Sender::Failure objects represented
17             #pod by this multi.
18             #pod
19             #pod =cut
20              
21             has failures => (
22             is => 'ro',
23             isa => ArrayRef,
24             required => 1,
25             reader => '__get_failures',
26             );
27              
28 9     9   11 sub __failures { @{$_[0]->__get_failures} }
  9         32  
29              
30             sub failures {
31 9     9 1 525 my ($self) = @_;
32 9 50       29 return $self->__failures if wantarray;
33 0 0       0 return if ! defined wantarray;
34              
35 0         0 Carp::carp("failures in scalar context is deprecated and WILL BE REMOVED");
36 0         0 return $self->__get_failures;
37             }
38              
39             sub recipients {
40 3     3 1 932 my ($self) = @_;
41 3         8 my @rcpts = map { $_->recipients } $self->failures;
  3         10  
42              
43 3 50       20 return @rcpts if wantarray;
44 0 0       0 return if ! defined wantarray;
45              
46 0         0 Carp::carp("recipients in scalar context is deprecated and WILL BE REMOVED");
47 0         0 return \@rcpts;
48             }
49              
50             #pod =method isa
51             #pod
52             #pod A multiple failure will report that it is a Permanent or Temporary if all of
53             #pod its contained failures are failures of that type.
54             #pod
55             #pod =cut
56              
57             sub isa {
58 29     29 1 6901 my ($self, $class) = @_;
59              
60 29 100 100     153 if (
61             $class eq 'Email::Sender::Failure::Permanent'
62             or
63             $class eq 'Email::Sender::Failure::Temporary'
64             ) {
65 4         11 my @failures = $self->failures;
66 4 100       8 return 1 if @failures == grep { $_->isa($class) } @failures;
  6         41  
67             }
68              
69 26         146 return $self->SUPER::isa($class);
70             }
71              
72 6     6   41 no Moo;
  6         12  
  6         36  
73             1;
74              
75             __END__