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. --- lib/Sietima/Subscriber.pm | 10 +++++----- lib/Sietima/Types.pm | 6 +++--- 2 files changed, 8 insertions(+), 8 deletions(-) (limited to 'lib') 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; -- cgit v1.2.3