| 1 | package EWS::Folder::ResultSet; | ||||||||||
| 2 | BEGIN { | ||||||||||
| 3 | 1 | ▶ | $EWS::Folder::ResultSet::VERSION = '1.143070'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | } | ||||||||||
| 5 | |||||||||||
| 6 | 1 | ▶ | use Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 7 | 1 | ▶ | use MooseX::Iterator; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | 1 | ▶ | use EWS::Folder::Item; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 10 | |||||||||||
| 11 | 1 | has items => ( | |||||||||
| 12 | is => 'ro', | ||||||||||
| 13 | isa => 'ArrayRef[EWS::Folder::Item]', | ||||||||||
| 14 | required => 1, | ||||||||||
| 15 | ); | ||||||||||
| 16 | |||||||||||
| 17 | sub BUILDARGS { | ||||||||||
| 18 | 0 | ▶ | my ($class, @rest) = @_; | ||||||||
|
Subroutine
BUILDARGS: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||
| 19 | 0 | ▶ | my $params = (scalar @rest == 1 ? $rest[0] : {@rest}); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 20 | |||||||||||
| 21 | # promote hashes returned from Exchange into Item objects | ||||||||||
| 22 | 0 | my $items = [ map { EWS::Folder::Item->new($_) } | |||||||||
| 23 | 0 | @{$params->{items}} ]; | |||||||||
| 24 | |||||||||||
| 25 | # convert $items into a deletable HASH | ||||||||||
| 26 | 0 | my %hshItems = map { $_->{FolderId}->{Id} => $_ } @{$items}; | |||||||||
| 27 | |||||||||||
| 28 | 0 | $items = []; | |||||||||
| 29 | 0 | foreach my $item (values %hshItems) { | |||||||||
| 30 | 0 | ▶ | if ( exists( $hshItems{$item->{ParentFolderId}->{Id}} )) { | ||||||||
|
Branch: 1 branch
| |||||||||||
| 31 | # add item to parent's SubFolders array | ||||||||||
| 32 | 0 | push @{$hshItems{$item->{ParentFolderId}->{Id}}->{items}}, $item; | |||||||||
| 33 | } | ||||||||||
| 34 | else { | ||||||||||
| 35 | # item without parent in the hash means it must be kept | ||||||||||
| 36 | 0 | push @{$items}, $item; | |||||||||
| 37 | } | ||||||||||
| 38 | } | ||||||||||
| 39 | 0 | $params->{items} = $items; | |||||||||
| 40 | 0 | return $params; | |||||||||
| 41 | } | ||||||||||
| 42 | |||||||||||
| 43 | sub count { | ||||||||||
| 44 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
count: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||
| 45 | 0 | return scalar @{$self->items}; | |||||||||
| 46 | } | ||||||||||
| 47 | |||||||||||
| 48 | 1 | has iterator => ( | |||||||||
| 49 | is => 'ro', | ||||||||||
| 50 | isa => 'MooseX::Iterator::Array', | ||||||||||
| 51 | handles => [qw/ | ||||||||||
| 52 | next | ||||||||||
| 53 | has_next | ||||||||||
| 54 | peek | ||||||||||
| 55 | reset | ||||||||||
| 56 | /], | ||||||||||
| 57 | lazy_build => 1, | ||||||||||
| 58 | ); | ||||||||||
| 59 | |||||||||||
| 60 | sub _build_iterator { | ||||||||||
| 61 | 0 | ▶ | my $self = shift; | ||||||||
|
Subroutine
_build_iterator: not called CC=1 SCAR=6.9
| |||||||||||
| 62 | 0 | return MooseX::Iterator::Array->new( collection => $self->items ); | |||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 1 | __PACKAGE__->meta->make_immutable; | |||||||||
| 66 | 1 | ▶ | no Moose; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 67 | 1 | 1; | |||||||||