« lib/HTML/FormFu/Role/ContainsElementsSharedWithField.pm
↑ Summary
lib/HTML/FormFu/Filter/Split.pm »
| 1 | 7 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | package HTML::FormFu::Element::ComboBox; | ||||||||||||||||||||||||||||||||
| 4 | 7 | $HTML::FormFu::Element::ComboBox::VERSION = '2.09'; | |||||||||||||||||||||||||||||||
| 5 | # ABSTRACT: Select / Text hybrid | ||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 7 | ▶ | use Moose; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 7 | ▶ | use MooseX::Attribute::Chained; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 7 | extends 'HTML::FormFu::Element::Multi'; | |||||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||||||
| 11 | 7 | with 'HTML::FormFu::Role::Element::ProcessOptionsFromModel'; | |||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||
| 13 | 7 | ▶ | use HTML::FormFu::Util qw( _filter_components _parse_args ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | 7 | ▶ | use List::Util 1.33 qw( any ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 15 | 7 | ▶ | use Moose::Util qw( apply_all_roles ); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 7 | our @DEFER_TO_SELECT = qw( | |||||||||||||||||||||||||||||||
| 18 | empty_first | ||||||||||||||||||||||||||||||||
| 19 | empty_first_label | ||||||||||||||||||||||||||||||||
| 20 | values | ||||||||||||||||||||||||||||||||
| 21 | value_range | ||||||||||||||||||||||||||||||||
| 22 | ); | ||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||
| 24 | 7 | for my $name (@DEFER_TO_SELECT) { | |||||||||||||||||||||||||||||||
| 25 | 28 | has $name => ( is => 'rw', traits => ['Chained'] ); | |||||||||||||||||||||||||||||||
| 26 | } | ||||||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||||||
| 28 | 4 | ▶ | has select => ( is => 'rw', traits => ['Chained'], default => sub { {} } ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 29 | 4 | ▶ | has text => ( is => 'rw', traits => ['Chained'], default => sub { {} } ); | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | 7 | *default = \&value; | |||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||
| 33 | ## build get_Xs methods | ||||||||||||||||||||||||||||||||
| 34 | 7 | for my $method ( qw( | |||||||||||||||||||||||||||||||
| 35 | deflator filter | ||||||||||||||||||||||||||||||||
| 36 | constraint inflator | ||||||||||||||||||||||||||||||||
| 37 | validator transformer | ||||||||||||||||||||||||||||||||
| 38 | ) ) | ||||||||||||||||||||||||||||||||
| 39 | { | ||||||||||||||||||||||||||||||||
| 40 | 52 | ▶ | my $sub = sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 41 | 52 | my $self = shift; | |||||||||||||||||||||||||||||||
| 42 | 52 | my %args = _parse_args(@_); | |||||||||||||||||||||||||||||||
| 43 | 52 | my $get_method = "get_${method}s"; | |||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | 52 | my $accessor = "_${method}s"; | |||||||||||||||||||||||||||||||
| 46 | 52 | my @x = @{ $self->$accessor }; | |||||||||||||||||||||||||||||||
| 47 | 52 | push @x, map { @{ $_->$get_method(@_) } } @{ $self->_elements }; | |||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | 52 | return _filter_components( \%args, \@x ); | |||||||||||||||||||||||||||||||
| 50 | 42 | }; | |||||||||||||||||||||||||||||||
| 51 | |||||||||||||||||||||||||||||||||
| 52 | 42 | my $name = __PACKAGE__ . "::get_${method}s"; | |||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | ## no critic (ProhibitNoStrict); | ||||||||||||||||||||||||||||||||
| 55 | 7 | ▶ | no strict 'refs'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||
| 57 | 42 | *{$name} = $sub; | |||||||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | 4 | ▶ | after BUILD => sub { | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 61 | 4 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 4 | $self->multi_value(1); | |||||||||||||||||||||||||||||||
| 64 | 4 | $self->empty_first(1); | |||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | 4 | return; | |||||||||||||||||||||||||||||||
| 67 | 7 | }; | |||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 1 | ▶ | sub options { | ||||||||||||||||||||||||||||||
|
Subroutine
options: called CC=4 SCAR=19.4
Pod
documented
| |||||||||||||||||||||||||||||||||
| 70 | 1 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||||||
| 72 | 1 | ▶ | if (@args) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 73 | 1 | ▶ | $self->{options} = @args == 1 ? $args[0] : \@args; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 1 | return $self; | |||||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | # we're being called as a getter! | ||||||||||||||||||||||||||||||||
| 80 | # are the child elements made yet? | ||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||
| 82 | 0 | ▶ | if ( !@{ $self->_elements } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||
| 84 | # need to build the children, so we can return the select options | ||||||||||||||||||||||||||||||||
| 85 | 0 | $self->_add_elements; | |||||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||||||
| 88 | 0 | return $self->_elements->[0]->options; | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | 47 | ▶ | sub value { | ||||||||||||||||||||||||||||||
|
Subroutine
value: called CC=3 SCAR=11.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 93 | 47 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 47 | ▶ | if ( @_ > 1 ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 96 | 2 | $self->{value} = $value; | |||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||
| 98 | # if we're already built - i.e. process() has been called, | ||||||||||||||||||||||||||||||||
| 99 | # call default() on our children | ||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||
| 101 | 2 | ▶ | if ( @{ $self->_elements } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 102 | 2 | $self->_combobox_defaults; | |||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||
| 104 | 2 | $self->_elements->[0]->default( $self->select->{default} ); | |||||||||||||||||||||||||||||||
| 105 | 2 | $self->_elements->[1]->default( $self->text->{default} ); | |||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | 2 | return $self; | |||||||||||||||||||||||||||||||
| 109 | } | ||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||
| 111 | 45 | return $self->{value}; | |||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | 15 | ▶ | sub _add_elements { | ||||||||||||||||||||||||||||||
|
Subroutine
_add_elements: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 115 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||
| 117 | 15 | $self->_elements( [] ); | |||||||||||||||||||||||||||||||
| 118 | |||||||||||||||||||||||||||||||||
| 119 | 15 | $self->_add_select; | |||||||||||||||||||||||||||||||
| 120 | 15 | $self->_add_text; | |||||||||||||||||||||||||||||||
| 121 | |||||||||||||||||||||||||||||||||
| 122 | 15 | $self->_combobox_defaults; | |||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | 15 | return; | |||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||
| 126 | |||||||||||||||||||||||||||||||||
| 127 | 17 | ▶ | sub _combobox_defaults { | ||||||||||||||||||||||||||||||
|
Subroutine
_combobox_defaults: called CC=7 SCAR=19.6
| |||||||||||||||||||||||||||||||||
| 128 | 17 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 129 | |||||||||||||||||||||||||||||||||
| 130 | 17 | ▶ | if ( defined( my $default = $self->default ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | 7 | ▶ | if ( !$self->form->submitted || $self->render_processed_value ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
not $self->form->submitted or $self->render_processed_value
MC/DC50%1/2
not $self->form->submitted or $self->render_processed_value
not $self->form->submitted
$self->render_processed_value
Truth table66%2/3
not(A) or B
A= not $self->form->submittedB= $self->render_processed_value
| |||||||||||||||||||||||||||||||||
| 133 | 5 | for my $deflator ( @{ $self->_deflators } ) { | |||||||||||||||||||||||||||||||
| 134 | 0 | $default = $deflator->process($default); | |||||||||||||||||||||||||||||||
| 135 | } | ||||||||||||||||||||||||||||||||
| 136 | } | ||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||
| 138 | 7 | my $select_options = $self->_elements->[0]->options; | |||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||
| 140 | 7 | ▶ | if ( $default ne '' | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$default ne "" and &any(sub {
$_->{"value"} eq $default;
}
, @$select_options)
MC/DC50%1/2
$default ne "" and &any(sub {
$_->{"value"} eq $default;
}
, @$select_options)
$default ne ""
&any(sub {
$_->{"value"} eq $default;
}
, @$select_options)
Truth table66%2/3
A and B
A= $default ne ""B= &any(sub {
$_->{"value"} eq $default;
}
, @$select_options)
| |||||||||||||||||||||||||||||||||
| 141 | 24 | ▶ | && any { $_->{value} eq $default } @$select_options ) | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 142 | { | ||||||||||||||||||||||||||||||||
| 143 | 2 | $self->select->{default} = $default; | |||||||||||||||||||||||||||||||
| 144 | 2 | $self->text->{default} = undef; | |||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||
| 146 | else { | ||||||||||||||||||||||||||||||||
| 147 | 5 | $self->select->{default} = undef; | |||||||||||||||||||||||||||||||
| 148 | 5 | $self->text->{default} = $default; | |||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||
| 150 | } | ||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | 17 | return; | |||||||||||||||||||||||||||||||
| 153 | } | ||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||
| 155 | 15 | ▶ | sub _add_select { | ||||||||||||||||||||||||||||||
|
Subroutine
_add_select: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 156 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||
| 158 | 15 | my $select = $self->select; | |||||||||||||||||||||||||||||||
| 159 | |||||||||||||||||||||||||||||||||
| 160 | 15 | my $select_name = _build_field_name( $self, 'select' ); | |||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | 15 | my $select_element = $self->element( | |||||||||||||||||||||||||||||||
| 163 | { type => 'Select', | ||||||||||||||||||||||||||||||||
| 164 | name => $select_name, | ||||||||||||||||||||||||||||||||
| 165 | } ); | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | 15 | apply_all_roles( $select_element, | |||||||||||||||||||||||||||||||
| 168 | 'HTML::FormFu::Role::Element::MultiElement' ); | ||||||||||||||||||||||||||||||||
| 169 | |||||||||||||||||||||||||||||||||
| 170 | 15 | for my $method (@DEFER_TO_SELECT) { | |||||||||||||||||||||||||||||||
| 171 | 60 | ▶ | if ( defined( my $value = $self->$method ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 172 | 27 | $select_element->$method($value); | |||||||||||||||||||||||||||||||
| 173 | } | ||||||||||||||||||||||||||||||||
| 174 | } | ||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||
| 176 | 15 | ▶ | if ( !@{ $select_element->options } ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | # we need to access the hashkey directly, | ||||||||||||||||||||||||||||||||
| 179 | # otherwise we'll have a loop | ||||||||||||||||||||||||||||||||
| 180 | 3 | $select_element->options( $self->{options} ); | |||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | 15 | ▶ | if ( defined( my $default = $select->{default} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 184 | 1 | $select_element->default($default); | |||||||||||||||||||||||||||||||
| 185 | } | ||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||
| 187 | 15 | return; | |||||||||||||||||||||||||||||||
| 188 | } | ||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||
| 190 | 15 | ▶ | sub _add_text { | ||||||||||||||||||||||||||||||
|
Subroutine
_add_text: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 191 | 15 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 192 | |||||||||||||||||||||||||||||||||
| 193 | 15 | my $text = $self->text; | |||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||
| 195 | 15 | my $text_name = _build_field_name( $self, 'text' ); | |||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||
| 197 | 15 | my $text_element = $self->element( | |||||||||||||||||||||||||||||||
| 198 | { type => 'Text', | ||||||||||||||||||||||||||||||||
| 199 | name => $text_name, | ||||||||||||||||||||||||||||||||
| 200 | } ); | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | 15 | apply_all_roles( $text_element, | |||||||||||||||||||||||||||||||
| 203 | 'HTML::FormFu::Role::Element::MultiElement' ); | ||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||
| 205 | 15 | ▶ | if ( defined( my $default = $text->{default} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 206 | 4 | $text_element->default($default); | |||||||||||||||||||||||||||||||
| 207 | } | ||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||
| 209 | 15 | return; | |||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||
| 212 | 11 | ▶ | sub get_select_field_nested_name { | ||||||||||||||||||||||||||||||
|
Subroutine
get_select_field_nested_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 213 | 11 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||
| 215 | 11 | my $select_name = _build_field_name( $self, 'select' ); | |||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||
| 217 | 11 | return $self->get_element( { name => $select_name } )->nested_name; | |||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||
| 219 | |||||||||||||||||||||||||||||||||
| 220 | 11 | ▶ | sub get_text_field_nested_name { | ||||||||||||||||||||||||||||||
|
Subroutine
get_text_field_nested_name: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 221 | 11 | my ($self) = @_; | |||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||
| 223 | 11 | my $text_name = _build_field_name( $self, 'text' ); | |||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||
| 225 | 11 | return $self->get_element( { name => $text_name } )->nested_name; | |||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||
| 228 | 52 | ▶ | sub _build_field_name { | ||||||||||||||||||||||||||||||
|
Subroutine
_build_field_name: called CC=2 SCAR=7.1
| |||||||||||||||||||||||||||||||||
| 229 | 52 | my ( $self, $type ) = @_; | |||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||
| 231 | 52 | my $options = $self->$type; | |||||||||||||||||||||||||||||||
| 232 | 52 | my $name; | |||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||
| 234 | 52 | ▶ | if ( defined( my $default_name = $options->{name} ) ) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 235 | 0 | $name = $default_name; | |||||||||||||||||||||||||||||||
| 236 | } | ||||||||||||||||||||||||||||||||
| 237 | else { | ||||||||||||||||||||||||||||||||
| 238 | 52 | $name = sprintf "%s_%s", $self->name, $type; | |||||||||||||||||||||||||||||||
| 239 | } | ||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||
| 241 | 52 | return $name; | |||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||
| 244 | 15 | ▶ | sub process { | ||||||||||||||||||||||||||||||
|
Subroutine
process: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 245 | 15 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||
| 247 | 15 | $self->_process_options_from_model; | |||||||||||||||||||||||||||||||
| 248 | |||||||||||||||||||||||||||||||||
| 249 | 15 | $self->_add_elements; | |||||||||||||||||||||||||||||||
| 250 | |||||||||||||||||||||||||||||||||
| 251 | 15 | return $self->SUPER::process(@args); | |||||||||||||||||||||||||||||||
| 252 | } | ||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||
| 254 | 11 | ▶ | sub process_input { | ||||||||||||||||||||||||||||||
|
Subroutine
process_input: called CC=5 SCAR=16.1
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 255 | 11 | my ( $self, $input ) = @_; | |||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||
| 257 | 11 | my $select_name = $self->get_select_field_nested_name; | |||||||||||||||||||||||||||||||
| 258 | 11 | my $text_name = $self->get_text_field_nested_name; | |||||||||||||||||||||||||||||||
| 259 | |||||||||||||||||||||||||||||||||
| 260 | 11 | my $select_value = $self->get_nested_hash_value( $input, $select_name ); | |||||||||||||||||||||||||||||||
| 261 | 11 | my $text_value = $self->get_nested_hash_value( $input, $text_name ); | |||||||||||||||||||||||||||||||
| 262 | |||||||||||||||||||||||||||||||||
| 263 | 11 | ▶ | if ( defined $text_value && length $text_value ) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
defined $text_value and length $text_value
MC/DC100%2/2
defined $text_value and length $text_value
defined $text_value
length $text_value
Truth table100%3/3
A and B
A= defined $text_valueB= length $text_value
| |||||||||||||||||||||||||||||||||
| 264 | 4 | $self->set_nested_hash_value( $input, $self->nested_name, $text_value, | |||||||||||||||||||||||||||||||
| 265 | ); | ||||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | ▶ | elsif ( defined $select_value && length $select_value ) { | |||||||||||||||||||||||||||||||
|
Condition66%2/3
defined $select_value and length $select_value
MC/DC50%1/2
defined $select_value and length $select_value
defined $select_value
length $select_value
Truth table66%2/3
A and B
A= defined $select_valueB= length $select_value
| |||||||||||||||||||||||||||||||||
| 268 | 6 | $self->set_nested_hash_value( $input, $self->nested_name, | |||||||||||||||||||||||||||||||
| 269 | $select_value, ); | ||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||
| 271 | |||||||||||||||||||||||||||||||||
| 272 | 11 | return $self->SUPER::process_input($input); | |||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||
| 275 | 6 | ▶ | sub render_data { | ||||||||||||||||||||||||||||||
|
Subroutine
render_data: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 276 | 6 | return shift->render_data_non_recursive(@_); | |||||||||||||||||||||||||||||||
| 277 | } | ||||||||||||||||||||||||||||||||
| 278 | |||||||||||||||||||||||||||||||||
| 279 | 6 | ▶ | sub render_data_non_recursive { | ||||||||||||||||||||||||||||||
|
Subroutine
render_data_non_recursive: called CC=2 SCAR=7.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 280 | 6 | my ( $self, $args ) = @_; | |||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | my $render = $self->SUPER::render_data_non_recursive( | ||||||||||||||||||||||||||||||||
| 283 | 6 | ▶ | { elements => [ map { $_->render_data } @{ $self->_elements } ], | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 284 | $args ? %$args : (), | ||||||||||||||||||||||||||||||||
| 285 | } ); | ||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||
| 287 | 6 | return $render; | |||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||
| 290 | 7 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||||||||||||||||
| 291 | |||||||||||||||||||||||||||||||||
| 292 | 7 | 1; | |||||||||||||||||||||||||||||||
| 293 | |||||||||||||||||||||||||||||||||
| 294 | __END__ | ||||||||||||||||||||||||||||||||