MenuGrinder/Plugin/DefaultTarget.pm untested

filter: Statementstmt 0.0% 0 / 17 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 0.0% 0 / 4 Podpod 0.0% 0 / 2 totaltotal 0.0% 0 / 34 CC 4 SCAR 25.1
CC
4
Cov
0%
item_mogrify
20.0
BEGIN
2.0
BEGIN
2.0
CRAP 12.3
1 package WWW::MenuGrinder::Plugin::DefaultTarget;
2 BEGIN {
3 $WWW::MenuGrinder::Plugin::DefaultTarget::VERSION = '0.06';
4 }
5  
6 # ABSTRACT: WWW::MenuGrinder plugin that sets a default link target.
7  
8 use Moose;
9  
10 with 'WWW::MenuGrinder::Role::ItemMogrifier';
11  
12 sub item_mogrify {
13 my ($self, $item) = @_;
14  
15 if (exists $item->{location} && !exists $item->{target}) {
16 if (ref $item->{location} eq "ARRAY") {
17 $item->{target} = "/" . $item->{location}[0];
18 } elsif (ref $item->{location} eq "HASH") {
19 $item->{target} = "/"; # XML::Simple is stupid.
20 } else {
21 $item->{target} = "/" . $item->{location};
22 }
23 }
24  
25 return $item;
26 }
27  
28 __PACKAGE__->meta->make_immutable;
29  
30 no Moose;
31 1;
32  
33  
34 __END__