File Coverage

blib/lib/Sietima/Role/ManualSubscription.pm
Criterion Covered Total %
statement 12 12 100.0
branch n/a
condition n/a
subroutine 4 4 100.0
pod n/a
total 16 16 100.0


line stmt bran cond sub pod time code
1             package Sietima::Role::ManualSubscription;
2 1     1   495 use Moo::Role;
  1         2  
  1         7  
3 1     1   303 use Sietima::Policy;
  1         3  
  1         7  
4 1     1   6 use Sietima::HeaderURI;
  1         2  
  1         15  
5 1     1   4 use namespace::clean;
  1         2  
  1         5  
6              
7             our $VERSION = '1.0.5'; # VERSION
8             # ABSTRACT: adds standard list-related headers to messages
9              
10             with 'Sietima::Role::WithOwner';
11              
12              
13             around list_addresses => sub($orig,$self) {
14             my $list_name = $self->name // 'the list';
15              
16             return +{
17             $self->$orig->%*,
18             subscribe => Sietima::HeaderURI->new_from_address(
19             $self->owner,
20             { subject => "Please add me to $list_name" },
21             ),
22             unsubscribe => Sietima::HeaderURI->new_from_address(
23             $self->owner,
24             { subject => "Please remove me from $list_name" },
25             ),
26             };
27             };
28              
29              
30             1;
31              
32             __END__
33              
34             =pod
35              
36             =encoding UTF-8
37              
38             =head1 NAME
39              
40             Sietima::Role::ManualSubscription - adds standard list-related headers to messages
41              
42             =head1 VERSION
43              
44             version 1.0.5
45              
46             =head1 SYNOPSIS
47              
48             my $sietima = Sietima->with_traits(
49             'Headers',
50             'ManualSubscription',
51             )->new({
52             %args,
53             owner => 'listmaster@example.com',
54             });
55              
56             =head1 DESCRIPTION
57              
58             A L<< C<Sietima> >> list with this role (and L<<
59             C<Headers>|Sietima::Role::Headers >>) applied will add, to each
60             outgoing message, headers specifying that to subscribe and
61             unsubscribe, people sould email the list owner.
62              
63             =head1 MODIFIED METHODS
64              
65             =head2 C<list_addresses>
66              
67             This method declares two "addresses", C<subscribe> and
68             C<unsubscribe>. Both are C<mailto:> URLs for the list
69             L<owner|Sietima::Role::WithOwner/owner>, with different subjects.
70              
71             =head1 AUTHOR
72              
73             Gianni Ceccarelli <dakkar@thenautilus.net>
74              
75             =head1 COPYRIGHT AND LICENSE
76              
77             This software is copyright (c) 2017 by Gianni Ceccarelli <dakkar@thenautilus.net>.
78              
79             This is free software; you can redistribute it and/or modify it under
80             the same terms as the Perl 5 programming language system itself.
81              
82             =cut