blib/lib/HTML/Widgets/NavMenu/Tree/Node.pm

filter: Statementstmt 100% 62 / 62 Branchbran 100% 12 / 12 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 16 / 16 Podpod 100% 9 / 9 totaltotal 100% 99 / 99 SCAR 22.0
CC
9
Cov
100%
set_values_from_hash_ref
5.0
expand
3.0
update_based_on_sub
2.0
CRAP 9.0
« blib/lib/HTML/Widgets/NavMenu/Iterator/NavMenu.pm ↑ Summary Build »
1 package HTML::Widgets::NavMenu::Tree::Node;
2 16 $HTML::Widgets::NavMenu::Tree::Node::VERSION = '1.0902';
3 16 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 16 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 16 ▶use parent 'HTML::Widgets::NavMenu::Object';
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 16 __PACKAGE__->mk_acc_ref(
9 [
10 qw(
11 CurrentlyActive expanded hide host li_id role rec_url_type
12 separator show_always skip subs text title url url_is_abs url_type
13 )
14 ]
15 );
16  
17 16 ▶use HTML::Widgets::NavMenu::ExpandVal ();
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19  
20 sub _init
21 {
22 363 ▶ my $self = shift;
Subroutine _init: called CC=1 SCAR=0.0
23  
24 363 $self->subs( [] );
25  
26 363 return $self;
27 }
28  
29  
30 sub expand
31 {
32 155 ▶ my $self = shift;
Subroutine expand: called CC=3 SCAR=11.0
Pod documented
33 155 ▶ my $v =
Branch: 1 branch
BranchTrueFalseTotal
@_ ? : 73 82 155
34 @_
35 ? ( shift(@_) )
36 : HTML::Widgets::NavMenu::ExpandVal->new( { capture => 1 } );
37  
38 # Don't set it to something if it's already capture_expanded(),
39 # otherwise it can set as a non-capturing expansion.
40 155 ▶ if ( !$self->capture_expanded() )
Branch: 1 branch
BranchTrueFalseTotal
unless ($self->capture_expanded) 109 46 155
41 {
42 109 $self->expanded($v);
43 }
44 155 return 0;
45 }
46  
47  
48 sub mark_as_current
49 {
50 28 ▶ my $self = shift;
Subroutine mark_as_current: called CC=1 SCAR=0.0
Pod documented
51 28 $self->expand();
52 28 $self->CurrentlyActive(1);
53 28 return 0;
54 }
55  
56 sub _process_new_sub
57 {
58 304 ▶ my $self = shift;
Subroutine _process_new_sub: called CC=1 SCAR=0.0
59 304 my $sub = shift;
60 304 $self->update_based_on_sub($sub);
61 }
62  
63  
64 sub update_based_on_sub
65 {
66 338 ▶ my $self = shift;
Subroutine update_based_on_sub: called CC=2 SCAR=6.9
Pod documented
67 338 my $sub = shift;
68 338 ▶ if ( my $expand_val = $sub->expanded() )
Branch: 1 branch
BranchTrueFalseTotal
if (my $expand_val = $sub->expanded) 55 283 338
69 {
70 55 $self->expand($expand_val);
71 }
72 }
73  
74  
75 sub add_sub
76 {
77 304 ▶ my $self = shift;
Subroutine add_sub: called CC=1 SCAR=0.0
Pod documented
78 304 my $sub = shift;
79 304 push( @{ $self->subs }, $sub );
80 304 $self->_process_new_sub($sub);
81 304 return 0;
82 }
83  
84  
85 sub get_nth_sub
86 {
87 104 ▶ my $self = shift;
Subroutine get_nth_sub: called CC=1 SCAR=0.0
Pod documented
88 104 my $idx = shift;
89 104 return $self->subs()->[$idx];
90 }
91  
92 sub _num_subs
93 {
94 105 ▶ my $self = shift;
Subroutine _num_subs: called CC=1 SCAR=0.0
95 105 return scalar( @{ $self->subs() } );
96 }
97  
98  
99 sub list_regular_keys
100 {
101 353 ▶ my $self = shift;
Subroutine list_regular_keys: called CC=1 SCAR=0.0
Pod documented
102  
103 return (
104 353 qw(host li_id rec_url_type role show_always text title url url_type));
105 }
106  
107  
108 sub list_boolean_keys
109 {
110 353 ▶ my $self = shift;
Subroutine list_boolean_keys: called CC=1 SCAR=0.0
Pod documented
111  
112 353 return (qw(hide separator skip url_is_abs));
113 }
114  
115  
116 sub set_values_from_hash_ref
117 {
118 353 ▶ my $self = shift;
Subroutine set_values_from_hash_ref: called CC=5 SCAR=16.1
Pod documented
119 353 my $sub_contents = shift;
120  
121 353 foreach my $key ( $self->list_regular_keys() )
122 {
123 3177 ▶ if ( exists( $sub_contents->{$key} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $sub_contents->{$key}) 905 2272 3177
124 {
125 905 $self->$key( $sub_contents->{$key} );
126 }
127 }
128  
129 353 foreach my $key ( $self->list_boolean_keys() )
130 {
131 1412 ▶ if ( $sub_contents->{$key} )
Branch: 1 branch
BranchTrueFalseTotal
if ($sub_contents->{$key}) 19 1393 1412
132 {
133 19 $self->$key(1);
134 }
135 }
136 }
137  
138  
139 sub capture_expanded
140 {
141 398 ▶ my $self = shift;
Subroutine capture_expanded: called CC=2 SCAR=6.9
Pod documented
142  
143 398 ▶ if ( my $e = $self->expanded() )
Branch: 1 branch
BranchTrueFalseTotal
if (my $e = $self->expanded) { } 73 325 398
144 {
145 73 return $e->is_capturing();
146 }
147 else
148 {
149 325 return;
150 }
151 }
152  
153  
154 16 1;
155  
156 __END__
« blib/lib/HTML/Widgets/NavMenu/Iterator/NavMenu.pm ↑ Summary Build »