| 1 | #!/usr/bin/perl | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | package Mail::Summary::Tools::Summary::List; | ||||||||||||||||||
| 4 | 5 | ▶ | use Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | 5 | ▶ | use Mail::Summary::Tools::Summary::Thread; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 5 | has name => ( | |||||||||||||||||
| 9 | isa => "Str", | ||||||||||||||||||
| 10 | is => "rw", | ||||||||||||||||||
| 11 | required => 0, | ||||||||||||||||||
| 12 | ); | ||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | has title => ( | ||||||||||||||||||
| 15 | isa => "Str", | ||||||||||||||||||
| 16 | is => "rw", | ||||||||||||||||||
| 17 | lazy => 1, | ||||||||||||||||||
| 18 | 1 | ▶ | default => sub { $_[0]->name }, | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 19 | 5 | ); | |||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | has threads => ( | ||||||||||||||||||
| 22 | isa => "ArrayRef", | ||||||||||||||||||
| 23 | is => "rw", | ||||||||||||||||||
| 24 | auto_deref => 1, | ||||||||||||||||||
| 25 | 1 | ▶ | default => sub { [ ] }, | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 26 | 6 | ▶ | trigger => sub { $_[0]->_reindex_message_ids }, | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 27 | 5 | ); | |||||||||||||||||
| 28 | |||||||||||||||||||
| 29 | 5 | has extra => ( | |||||||||||||||||
| 30 | isa => "HashRef", | ||||||||||||||||||
| 31 | is => "rw", | ||||||||||||||||||
| 32 | required => 0, | ||||||||||||||||||
| 33 | ); | ||||||||||||||||||
| 34 | |||||||||||||||||||
| 35 | has _message_id_index => ( | ||||||||||||||||||
| 36 | isa => "HashRef", | ||||||||||||||||||
| 37 | is => "rw", | ||||||||||||||||||
| 38 | lazy => 1, | ||||||||||||||||||
| 39 | 1 | ▶ | default => sub { $_[0]->_reindex_message_ids }, | ||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 40 | 5 | ); | |||||||||||||||||
| 41 | |||||||||||||||||||
| 42 | |||||||||||||||||||
| 43 | 4 | ▶ | sub get_thread_by_id { | ||||||||||||||||
|
Subroutine
get_thread_by_id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 44 | 4 | my ( $self, $message_id ) = @_; | |||||||||||||||||
| 45 | |||||||||||||||||||
| 46 | 4 | $self->_message_id_index->{$message_id}; | |||||||||||||||||
| 47 | } | ||||||||||||||||||
| 48 | |||||||||||||||||||
| 49 | 7 | ▶ | sub _reindex_message_ids { | ||||||||||||||||
|
Subroutine
_reindex_message_ids: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 50 | 7 | my $self = shift; | |||||||||||||||||
| 51 | |||||||||||||||||||
| 52 | 7 | my %index = map { $_->message_id => $_ } $self->threads; | |||||||||||||||||
| 53 | |||||||||||||||||||
| 54 | 7 | $self->_message_id_index(\%index); | |||||||||||||||||
| 55 | |||||||||||||||||||
| 56 | 7 | return \%index; | |||||||||||||||||
| 57 | } | ||||||||||||||||||
| 58 | |||||||||||||||||||
| 59 | 1 | ▶ | sub add_threads { | ||||||||||||||||
|
Subroutine
add_threads: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 60 | 1 | my ( $self, @threads ) = @_; | |||||||||||||||||
| 61 | 1 | @{ $self->_message_id_index }{ map { $_->message_id } @threads } = @threads; | |||||||||||||||||
| 62 | 1 | push @{ $self->threads }, @threads; | |||||||||||||||||
| 63 | } | ||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | 1 | ▶ | sub load { | ||||||||||||||||
|
Subroutine
load: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||
| 66 | 1 | my ( $class, $hash, %options ) = @_; | |||||||||||||||||
| 67 | |||||||||||||||||||
| 68 | 1 | $hash->{threads} = [ map { Mail::Summary::Tools::Summary::Thread->load($_, %options) } @{ $hash->{threads} } ]; | |||||||||||||||||
| 69 | |||||||||||||||||||
| 70 | 1 | $class->new( %{ $options{list} }, %$hash ); | |||||||||||||||||
| 71 | } | ||||||||||||||||||
| 72 | |||||||||||||||||||
| 73 | 1 | ▶ | sub to_hash { | ||||||||||||||||
|
Subroutine
to_hash: called CC=4 SCAR=15.2
Pod
undocumented
| |||||||||||||||||||
| 74 | 1 | my $self = shift; | |||||||||||||||||
| 75 | |||||||||||||||||||
| 76 | return { | ||||||||||||||||||
| 77 | ( $self->name ? ( name => $self->name ) : () ),, | ||||||||||||||||||
| 78 | ( $self->title ? ( title => $self->title ) : () ), | ||||||||||||||||||
| 79 | ( $self->extra ? ( extra => $self->extra ) : () ), | ||||||||||||||||||
| 80 | 1 | ▶ | threads => [ map { $_->to_hash } $self->threads ], | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 81 | }; | ||||||||||||||||||
| 82 | } | ||||||||||||||||||
| 83 | |||||||||||||||||||
| 84 | 5 | __PACKAGE__; | |||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | __END__ | ||||||||||||||||||