| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package SyForm::Values; |
|
2
|
|
|
|
|
|
|
BEGIN { |
|
3
|
6
|
|
|
6
|
|
3485
|
$SyForm::Values::AUTHORITY = 'cpan:GETTY'; |
|
4
|
|
|
|
|
|
|
} |
|
5
|
|
|
|
|
|
|
# ABSTRACT: Values given of the fields through the process args |
|
6
|
|
|
|
|
|
|
$SyForm::Values::VERSION = '0.103'; |
|
7
|
6
|
|
|
6
|
|
41
|
use Moo; |
|
|
6
|
|
|
|
|
13
|
|
|
|
6
|
|
|
|
|
37
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
with qw( |
|
10
|
|
|
|
|
|
|
MooX::Traits |
|
11
|
|
|
|
|
|
|
SyForm::ValuesRole::Verify |
|
12
|
|
|
|
|
|
|
); |
|
13
|
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
has syform => ( |
|
15
|
|
|
|
|
|
|
is => 'ro', |
|
16
|
|
|
|
|
|
|
required => 1, |
|
17
|
|
|
|
|
|
|
handles => [qw( |
|
18
|
|
|
|
|
|
|
field |
|
19
|
|
|
|
|
|
|
field_names |
|
20
|
|
|
|
|
|
|
)], |
|
21
|
|
|
|
|
|
|
); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has values => ( |
|
24
|
|
|
|
|
|
|
is => 'ro', |
|
25
|
|
|
|
|
|
|
required => 1, |
|
26
|
|
|
|
|
|
|
); |
|
27
|
0
|
|
|
0
|
0
|
0
|
sub as_hashref { $_[0]->values } |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
has results => ( |
|
30
|
|
|
|
|
|
|
is => 'lazy', |
|
31
|
|
|
|
|
|
|
); |
|
32
|
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub _build_results { |
|
34
|
11
|
|
|
11
|
|
106
|
my ( $self ) = @_; |
|
35
|
11
|
|
|
|
|
22
|
my $results; |
|
36
|
11
|
|
|
|
|
20
|
eval { |
|
37
|
11
|
|
|
|
|
17
|
my %results_args; |
|
38
|
11
|
|
|
|
|
212
|
for my $field ($self->syform->fields->Values) { |
|
39
|
38
|
|
|
|
|
236
|
my %field_results_args = $field->results_args_by_values($self); |
|
40
|
38
|
|
|
|
|
107
|
$results_args{$_} = $field_results_args{$_} for keys %field_results_args; |
|
41
|
|
|
|
|
|
|
} |
|
42
|
11
|
|
|
|
|
246
|
$results = $self->create_results( %results_args ); |
|
43
|
|
|
|
|
|
|
}; |
|
44
|
11
|
50
|
|
|
|
8300
|
SyForm->throw( UnknownErrorOnValuesBuildResults => $self, $@ ) if $@; |
|
45
|
11
|
|
|
|
|
62
|
return $results; |
|
46
|
|
|
|
|
|
|
} |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub create_results { |
|
49
|
|
|
|
|
|
|
my ( $self, %args ) = @_; |
|
50
|
|
|
|
|
|
|
my %results; |
|
51
|
|
|
|
|
|
|
for my $field ($self->syform->fields->Values) { |
|
52
|
|
|
|
|
|
|
my $name = $field->name; |
|
53
|
|
|
|
|
|
|
$results{$name} = delete $args{$name} if exists $args{$name}; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
return $self->syform->loaded_results_class->new({ |
|
56
|
|
|
|
|
|
|
values => $self, |
|
57
|
|
|
|
|
|
|
results => { %results }, |
|
58
|
|
|
|
|
|
|
%args |
|
59
|
|
|
|
|
|
|
}); |
|
60
|
|
|
|
|
|
|
} |
|
61
|
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
sub get_value { |
|
63
|
38
|
|
|
38
|
0
|
68
|
my ( $self, $name ) = @_; |
|
64
|
38
|
|
|
|
|
129
|
return $self->values->{$name}; |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
sub has_value { |
|
68
|
66
|
|
|
66
|
0
|
125
|
my ( $self, $name ) = @_; |
|
69
|
66
|
100
|
|
|
|
378
|
return exists($self->values->{$name}) ? 1 : 0; |
|
70
|
|
|
|
|
|
|
} |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
1; |
|
73
|
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
__END__ |
|
75
|
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=pod |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=head1 NAME |
|
79
|
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
SyForm::Values - Values given of the fields through the process args |
|
81
|
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
=head1 VERSION |
|
83
|
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
version 0.103 |
|
85
|
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
=head1 AUTHOR |
|
87
|
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
Torsten Raudssus <torsten@raudss.us> |
|
89
|
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
|
91
|
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Torsten Raudssus. |
|
93
|
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
|
95
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
|
96
|
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=cut |