File Coverage

blib/lib/Sietima/Role/NoMail.pm
Criterion Covered Total %
statement 9 9 100.0
branch n/a
condition n/a
subroutine 3 3 100.0
pod n/a
total 12 12 100.0


line stmt bran cond sub pod time code
1             package Sietima::Role::NoMail;
2 1     1   493 use Moo::Role;
  1         2  
  1         7  
3 1     1   319 use Sietima::Policy;
  1         2  
  1         18  
4 1     1   5 use namespace::clean;
  1         2  
  1         7  
5              
6             our $VERSION = '1.0.5'; # VERSION
7             # ABSTRACT: don't send mail to those who don't want it
8              
9              
10             around subscribers_to_send_to => sub ($orig,$self,$mail) {
11             return [
12             grep { $_->prefs->{wants_mail} // 1 }
13             $self->$orig($mail)->@*,
14             ];
15             };
16              
17             1;
18              
19             __END__
20              
21             =pod
22              
23             =encoding UTF-8
24              
25             =head1 NAME
26              
27             Sietima::Role::NoMail - don't send mail to those who don't want it
28              
29             =head1 VERSION
30              
31             version 1.0.5
32              
33             =head1 SYNOPSIS
34              
35             my $sietima = Sietima->with_traits('NoMail')->new({
36             %args,
37             subscribers => [
38             { primary => 'write-only@example.com', prefs => { wants_mail => 0 } },
39             @other_subscribers,
40             ],
41             });
42              
43             =head1 DESCRIPTION
44              
45             A L<< C<Sietima> >> list with this role applied will not send messages
46             to subscribers that have the C<wants_mail> preference set to a false
47             value.
48              
49             =head1 MODIFIED METHODS
50              
51             =head2 C<subscribers_to_send_to>
52              
53             Filters out subscribers that have the C<wants_mail> preference set to
54             a false value.
55              
56             =head1 AUTHOR
57              
58             Gianni Ceccarelli <dakkar@thenautilus.net>
59              
60             =head1 COPYRIGHT AND LICENSE
61              
62             This software is copyright (c) 2017 by Gianni Ceccarelli <dakkar@thenautilus.net>.
63              
64             This is free software; you can redistribute it and/or modify it under
65             the same terms as the Perl 5 programming language system itself.
66              
67             =cut