From dcbf392ecd8e22ad4d3d326b83d89d749ca88481 Mon Sep 17 00:00:00 2001 From: dakkar Date: Sun, 5 Feb 2017 13:29:42 +0000 Subject: ::Subscriber 'raw_address' is now 'primary' It was a horrible name. The coercion from hashref is also simplified this way. --- example/sietima | 4 ++-- lib/Sietima/Subscriber.pm | 10 +++++----- lib/Sietima/Types.pm | 6 +++--- t/tests/sietima/role/nomail.t | 4 ++-- t/tests/sietima/role/replyto.t | 4 ++-- t/tests/sietima/role/subscriberonly/drop.t | 2 +- t/tests/sietima/subscriber.t | 4 ++-- 7 files changed, 17 insertions(+), 17 deletions(-) diff --git a/example/sietima b/example/sietima index 2e0f338..261a943 100755 --- a/example/sietima +++ b/example/sietima @@ -24,8 +24,8 @@ Sietima::CmdLine->new({ subject_tag => 'Test', subscribers => [ 'dakkar-a@thenautilus.net', - { address => 'dakkar-b@thenautilus.net', aliases => [ 'dakkar-bis@thenautilus.net' ] }, - { address => 'dakkar-c@thenautilus.net', prefs => { wants_mail => 0 } }, + { primary => 'dakkar-b@thenautilus.net', aliases => [ 'dakkar-bis@thenautilus.net' ] }, + { primary => 'dakkar-c@thenautilus.net', prefs => { wants_mail => 0 } }, ], }, })->run; diff --git a/lib/Sietima/Subscriber.pm b/lib/Sietima/Subscriber.pm index 649b2e5..96c7d3b 100644 --- a/lib/Sietima/Subscriber.pm +++ b/lib/Sietima/Subscriber.pm @@ -21,7 +21,7 @@ subscriber, together with possible aliases and preferences. All attributes are read-only. -=head2 C +=head2 C Required L<< C >> object, coercible from a string. @@ -30,7 +30,7 @@ will receive messages from the mailing list. =cut -has raw_address => ( +has primary => ( isa => Address, is => 'ro', required => 1, @@ -83,7 +83,7 @@ has prefs => ( Given a L<< C >> object (or a string), this method returns true if the address is equivalent to the -L or any of the L. +L or any of the L. This method should be used to determine whether an address belongs to a subscriber. @@ -97,7 +97,7 @@ sub match { my ($self,$addr) = $check->(@_); return any { $addr->address eq $_->address } - $self->raw_address, $self->aliases->@*; + $self->primary, $self->aliases->@*; } =head2 C
@@ -107,7 +107,7 @@ sub match { =head2 C These methods delegate to L<< C >>'s methods of the -same name, invoked on the L. +same name, invoked on the L. =cut diff --git a/lib/Sietima/Types.pm b/lib/Sietima/Types.pm index 3288972..1c75b1f 100644 --- a/lib/Sietima/Types.pm +++ b/lib/Sietima/Types.pm @@ -165,14 +165,14 @@ class_type Subscriber, { class => 'Sietima::Subscriber' }; declare_coercion SubscriberFromAddress, to_type Subscriber, from Address, - q{ Sietima::Subscriber->new(raw_address=>$_) }; + q{ Sietima::Subscriber->new(primary=>$_) }; declare_coercion SubscriberFromStr, to_type Subscriber, from Str, - q{ Sietima::Subscriber->new(raw_address=>(Email::Address->parse($_))[0]) }; + q{ Sietima::Subscriber->new(primary=>(Email::Address->parse($_))[0]) }; declare_coercion SubscriberFromHashRef, to_type Subscriber, from HashRef, - q{ my $a = delete $_->{address};Sietima::Subscriber->new({raw_address => $a, $_->%* }) }; + q{ Sietima::Subscriber->new($_) }; 1; diff --git a/t/tests/sietima/role/nomail.t b/t/tests/sietima/role/nomail.t index 1ff724c..2449f5a 100644 --- a/t/tests/sietima/role/nomail.t +++ b/t/tests/sietima/role/nomail.t @@ -7,7 +7,7 @@ subtest 'disabled' => sub { with_traits => ['NoMail'], subscribers => [ { - address => 'one@users.example.com', + primary => 'one@users.example.com', prefs => { wants_mail => 0 }, }, 'two@users.example.com', @@ -25,7 +25,7 @@ subtest 'enabled' => sub { with_traits => ['NoMail'], subscribers => [ { - address => 'one@users.example.com', + primary => 'one@users.example.com', prefs => { wants_mail => 1 }, }, 'two@users.example.com', diff --git a/t/tests/sietima/role/replyto.t b/t/tests/sietima/role/replyto.t index 0ede95e..e39f8b3 100644 --- a/t/tests/sietima/role/replyto.t +++ b/t/tests/sietima/role/replyto.t @@ -81,7 +81,7 @@ subtest 'enabled for some' => sub { munge_reply_to => 0, subscribers => [ { - address => 'one@users.example.com', + primary => 'one@users.example.com', prefs => { munge_reply_to => 1 }, }, 'two@users.example.com', @@ -114,7 +114,7 @@ subtest 'disabled for some' => sub { munge_reply_to => 1, subscribers => [ { - address => 'one@users.example.com', + primary => 'one@users.example.com', prefs => { munge_reply_to => 0 }, }, 'two@users.example.com', diff --git a/t/tests/sietima/role/subscriberonly/drop.t b/t/tests/sietima/role/subscriberonly/drop.t index 77b4b5f..ac37346 100644 --- a/t/tests/sietima/role/subscriberonly/drop.t +++ b/t/tests/sietima/role/subscriberonly/drop.t @@ -5,7 +5,7 @@ use Test::Sietima; my @subscriber_addresses = ( 'one@users.example.com', { - address => 'two@users.example.com', + primary => 'two@users.example.com', aliases => [ 'two-two@users.example.com' ], }, ); diff --git a/t/tests/sietima/subscriber.t b/t/tests/sietima/subscriber.t index 23651a9..6761410 100644 --- a/t/tests/sietima/subscriber.t +++ b/t/tests/sietima/subscriber.t @@ -5,7 +5,7 @@ use Sietima::Subscriber; subtest 'simple' => sub { my $s = Sietima::Subscriber->new( - raw_address => 'Gino (pino) ', + primary => 'Gino (pino) ', ); is( @@ -22,7 +22,7 @@ subtest 'simple' => sub { subtest 'aliases' => sub { my $s = Sietima::Subscriber->new( - raw_address => 'Gino (pino) ', + primary => 'Gino (pino) ', aliases => [qw(also-gino@pino.example.com maybe-gino@rino.example.com)], ); -- cgit v1.2.3