File Coverage

blib/lib/Sietima/Role/WithOwner.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::WithOwner;
2 4     4   1810 use Moo::Role;
  4         9  
  4         19  
3 4     4   1137 use Sietima::Policy;
  4         8  
  4         21  
4 4     4   21 use Sietima::Types qw(Address AddressFromStr);
  4         6  
  4         25  
5 4     4   1490 use namespace::clean;
  4         7  
  4         18  
6              
7             our $VERSION = '1.0.5'; # VERSION
8             # ABSTRACT: role for lists with an owner
9              
10              
11             has owner => (
12             is => 'ro',
13             isa => Address,
14             required => 1,
15             coerce => AddressFromStr,
16             );
17              
18              
19             around list_addresses => sub($orig,$self) {
20             return +{
21             $self->$orig->%*,
22             owner => $self->owner,
23             };
24             };
25              
26             1;
27              
28             __END__
29              
30             =pod
31              
32             =encoding UTF-8
33              
34             =head1 NAME
35              
36             Sietima::Role::WithOwner - role for lists with an owner
37              
38             =head1 VERSION
39              
40             version 1.0.5
41              
42             =head1 SYNOPSIS
43              
44             my $sietima = Sietima->with_traits('WithOwner')->new({
45             %args,
46             owner => 'listmaster@example.com',
47             });
48              
49             =head1 DESCRIPTION
50              
51             This role adds an L<< /C<owner> >> attribute, and exposes it via the
52             L<< C<list_addresses>|Sietima/list_addresses >> method.
53              
54             On its own, this role is not very useful, but other roles (like L<<
55             C<SubscriberOnly::Moderate>|Sietima::Role::SubscriberOnly::Moderate
56             >>) can have uses for an owner address.
57              
58             =head1 ATTRIBUTES
59              
60             =head2 C<owner>
61              
62             Required instance of L<< C<Email::Address> >>, coercible from a
63             string. This is the address of the owner of the list.
64              
65             =head1 MODIFIED METHODS
66              
67             =head2 C<list_addresses>
68              
69             This method declares the C<owner> address.
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