package Sietima::Subscriber;
use Moo;
use Sietima::Policy;
use Types::Standard qw(ArrayRef HashRef Object);
use Type::Params -sigs;
use Sietima::Types qw(Address AddressFromStr);
use Email::Address;
use List::AllUtils qw(any);
use namespace::clean;
our $VERSION = '1.1.2'; # VERSION
# ABSTRACT: a subscriber to a mailing list
has primary => (
isa => Address,
is => 'ro',
required => 1,
coerce => AddressFromStr,
handles => [qw(address name original)],
);
my $address_array = ArrayRef[
Address->plus_coercions(
AddressFromStr
)
];
has aliases => (
isa => $address_array,
is => 'lazy',
coerce => $address_array->coercion,
);
sub _build_aliases { +[] }
has prefs => (
isa => HashRef,
is => 'ro',
default => sub { +{} },
);
signature_for match => (
method => Object,
positional => [ Address->plus_coercions(AddressFromStr) ],
);
sub match($self,$addr) {
return any { $addr->address eq $_->address }
$self->primary, $self->aliases->@*;
}
1;
__END__
=pod
=encoding UTF-8
=head1 NAME
Sietima::Subscriber - a subscriber to a mailing list
=head1 VERSION
version 1.1.2
=head1 DESCRIPTION
This class holds the primary email address for a mailing list
subscriber, together with possible aliases and preferences.
=head1 ATTRIBUTES
All attributes are read-only.
=head2 C