| 1 | # Copyrights 2001-2023 by [Mark Overmeer <markov@cpan.org>]. | ||||||||||||||
| 2 | # For other contributors see ChangeLog. | ||||||||||||||
| 3 | # See the manual pages for details on the licensing terms. | ||||||||||||||
| 4 | # Pod stripped from pm file by OODoc 2.03. | ||||||||||||||
| 5 | # This code is part of distribution Mail-Message. Meta-POD processed with | ||||||||||||||
| 6 | # OODoc into POD and HTML manual-pages. See README.md | ||||||||||||||
| 7 | # Copyright Mark Overmeer. Licensed under the same terms as Perl itself. | ||||||||||||||
| 8 | |||||||||||||||
| 9 | package Mail::Message::Field::AddrGroup; | ||||||||||||||
| 10 | 24 | ▶ | use vars '$VERSION'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 11 | 24 | $VERSION = '3.013'; | |||||||||||||
| 12 | |||||||||||||||
| 13 | 24 | ▶ | use base 'User::Identity::Collection::Emails'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 14 | |||||||||||||||
| 15 | 24 | ▶ | use strict; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 16 | 24 | ▶ | use warnings; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 17 | |||||||||||||||
| 18 | |||||||||||||||
| 19 | 24 | ▶ | use overload '""' => 'string'; | ||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||
| 20 | |||||||||||||||
| 21 | #------------------------------------------ | ||||||||||||||
| 22 | |||||||||||||||
| 23 | |||||||||||||||
| 24 | sub string() | ||||||||||||||
| 25 | 53 | ▶ | { my $self = shift; | ||||||||||||
|
Subroutine
string: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||
| 26 | 53 | my $name = $self->name; | |||||||||||||
| 27 | 53 | my @addr = sort map $_->string, $self->addresses; | |||||||||||||
| 28 | |||||||||||||||
| 29 | 53 | local $" = ', '; | |||||||||||||
| 30 | |||||||||||||||
| 31 | 53 | ▶ | length $name ? "$name: @addr;" | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 32 | : @addr ? "@addr" | ||||||||||||||
| 33 | : ''; | ||||||||||||||
| 34 | } | ||||||||||||||
| 35 | |||||||||||||||
| 36 | #------------------------------------------ | ||||||||||||||
| 37 | |||||||||||||||
| 38 | |||||||||||||||
| 39 | sub coerce($@) | ||||||||||||||
| 40 | 1 | ▶ | { my ($class, $addr, %args) = @_; | ||||||||||||
|
Subroutine
coerce: called CC=5 SCAR=18.9
Pod
documented
| |||||||||||||||
| 41 | |||||||||||||||
| 42 | 1 | ▶ | return () unless defined $addr; | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 43 | |||||||||||||||
| 44 | 1 | ▶ | if(ref $addr) | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 45 | 1 | ▶ | { return $addr if $addr->isa($class); | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 46 | |||||||||||||||
| 47 | 1 | ▶ | return bless $addr, $class | ||||||||||||
|
Branch: 1 branch
| |||||||||||||||
| 48 | if $addr->isa('User::Identity::Collection::Emails'); | ||||||||||||||
| 49 | } | ||||||||||||||
| 50 | |||||||||||||||
| 51 | 0 | $class->log(ERROR => "Cannot coerce a ".(ref($addr)|'string'). | |||||||||||||
| 52 | " into a $class"); | ||||||||||||||
| 53 | 0 | (); | |||||||||||||
| 54 | } | ||||||||||||||
| 55 | |||||||||||||||
| 56 | |||||||||||||||
| 57 | #------------------------------------------ | ||||||||||||||
| 58 | |||||||||||||||
| 59 | |||||||||||||||
| 60 | sub addAddress(@) | ||||||||||||||
| 61 | 26 | ▶ | { my $self = shift; | ||||||||||||
|
Subroutine
addAddress: called CC=3 SCAR=11.4
Pod
documented
| |||||||||||||||
| 62 | |||||||||||||||
| 63 | 26 | ▶ | my $addr | ||||||||||||
|
Branch: 2 branches
| |||||||||||||||
| 64 | = @_ > 1 ? Mail::Message::Field::Address->new(@_) | ||||||||||||||
| 65 | : !$_[0] ? return () | ||||||||||||||
| 66 | : Mail::Message::Field::Address->coerce(shift); | ||||||||||||||
| 67 | |||||||||||||||
| 68 | 26 | $self->addRole($addr); | |||||||||||||
| 69 | 26 | $addr; | |||||||||||||
| 70 | } | ||||||||||||||
| 71 | |||||||||||||||
| 72 | |||||||||||||||
| 73 | # roles are stored in a hash, so produce | ||||||||||||||
| 74 | 74 | ▶ | sub addresses() { shift->roles } | ||||||||||||
|
Subroutine
addresses: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||
| 75 | |||||||||||||||
| 76 | #------------------------------------------ | ||||||||||||||
| 77 | |||||||||||||||
| 78 | |||||||||||||||
| 79 | 24 | 1; | |||||||||||||