File Coverage

blib/lib/Email/Sender/Transport/Wrapper.pm
Criterion Covered Total %
statement 21 23 91.3
branch 4 6 66.6
condition n/a
subroutine 6 7 85.7
pod 0 4 0.0
total 31 40 77.5


line stmt bran cond sub pod time code
1             package Email::Sender::Transport::Wrapper 2.500;
2             # ABSTRACT: a mailer to wrap a mailer for mailing mail
3              
4 3     3   3010 use Moo;
  3         7  
  3         17  
5             with 'Email::Sender::Transport';
6              
7 3     3   1394 use Email::Sender::Util;
  3         10  
  3         886  
8              
9             #pod =head1 DESCRIPTION
10             #pod
11             #pod Email::Sender::Transport::Wrapper wraps a transport, provided as the
12             #pod C argument to the constructor. It is provided as a simple way to
13             #pod use method modifiers to create wrapping classes.
14             #pod
15             #pod =cut
16              
17             has transport => (
18             is => 'ro',
19             does => 'Email::Sender::Transport',
20             required => 1,
21             );
22              
23             sub send_email {
24 2     2 0 143 my $self = shift;
25              
26 2         15 $self->transport->send_email(@_);
27             }
28              
29             sub is_simple {
30 2     2 0 14 return $_[0]->transport->is_simple;
31             }
32              
33             sub allow_partial_success {
34 0     0 0 0 return $_[0]->transport->allow_partial_success;
35             }
36              
37             sub BUILDARGS {
38 2     2 0 3174 my $self = shift;
39 2         18 my $href = $self->SUPER::BUILDARGS(@_);
40              
41 2 100       29 if (my $class = delete $href->{transport_class}) {
42             Carp::confess("given both a transport and transport_class")
43 1 50       4 if $href->{transport};
44              
45 1         2 my %arg;
46 1 50       3 for my $key (map {; /^transport_arg_(.+)$/ ? "$1" : () } keys %$href) {
  1         4  
47 0         0 $arg{$key} = delete $href->{"transport_arg_$key"};
48             }
49              
50 1         6 $href->{transport} = Email::Sender::Util->easy_transport($class, \%arg);
51             }
52              
53 2         77 return $href;
54             }
55              
56 3     3   24 no Moo;
  3         8  
  3         17  
57             1;
58              
59             __END__