File Coverage

blib/lib/Apache/ASP/CollectionItem.pm
Criterion Covered Total %
statement 12 12 100.0
branch 6 6 100.0
condition n/a
subroutine 4 4 100.0
pod 0 3 0.0
total 22 25 88.0


line stmt bran cond sub pod time code
1              
2             package Apache::ASP::CollectionItem;
3 46     46   276 use strict;
  46         82  
  46         16129  
4              
5             # for support of $Request->QueryString->('foo')->Item() syntax
6              
7             sub new {
8 23     23 0 33 my($package, $rv) = @_;
9 23         43 my @items = @$rv;
10 23 100       156 bless {
11             'Item' => $items[0],
12             'Items' => \@items,
13             'Count' => defined $items[0] ? scalar(@items) : 0,
14             }, $package;
15             }
16              
17 4     4 0 27 sub Count { shift->{Count} };
18              
19             sub Item {
20 16     16 0 28 my($self, $index) = @_;
21 16         25 my $items = $self->{Items};
22            
23 16 100       25 if(defined $index) {
24 2         11 $items->[$index-1];
25             } else {
26 14 100       75 wantarray ? @$items : $items->[0];
27             }
28             }
29              
30             1;