line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package SyForm::Role::Process; |
2
|
|
|
|
|
|
|
BEGIN { |
3
|
7
|
|
|
7
|
|
16007
|
$SyForm::Role::Process::AUTHORITY = 'cpan:GETTY'; |
4
|
|
|
|
|
|
|
} |
5
|
|
|
|
|
|
|
# ABSTRACT: SyForm role for processing |
6
|
|
|
|
|
|
|
$SyForm::Role::Process::VERSION = '0.103'; |
7
|
7
|
|
|
7
|
|
62
|
use Moo::Role; |
|
7
|
|
|
|
|
13
|
|
|
7
|
|
|
|
|
48
|
|
8
|
7
|
|
|
7
|
|
2459
|
use Module::Runtime qw( use_module ); |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
68
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
with qw( |
11
|
|
|
|
|
|
|
SyForm::Role::Verify |
12
|
|
|
|
|
|
|
SyForm::Role::HTML |
13
|
|
|
|
|
|
|
SyForm::Role::Bootstrap |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
########## |
17
|
|
|
|
|
|
|
# |
18
|
|
|
|
|
|
|
# Process |
19
|
|
|
|
|
|
|
# |
20
|
|
|
|
|
|
|
########## |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub process { |
23
|
8
|
|
|
8
|
0
|
10608
|
my ( $self, @args ) = @_; |
24
|
8
|
|
|
|
|
21
|
my $view; |
25
|
8
|
|
|
|
|
18
|
eval { $view = $self->process_view(@args) }; |
|
8
|
|
|
|
|
31
|
|
26
|
8
|
50
|
0
|
|
|
59
|
SyForm->throw( UnknownErrorOnProcess => $self,[@args], $@ || '$view is undefined' ) if $@ || !defined $view; |
|
|
|
33
|
|
|
|
|
27
|
8
|
|
|
|
|
41
|
return $view; |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
################# |
31
|
|
|
|
|
|
|
# |
32
|
|
|
|
|
|
|
# Process Values |
33
|
|
|
|
|
|
|
# |
34
|
|
|
|
|
|
|
################# |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
has values_class => ( |
37
|
|
|
|
|
|
|
is => 'lazy', |
38
|
|
|
|
|
|
|
); |
39
|
|
|
|
|
|
|
|
40
|
7
|
|
|
7
|
|
105
|
sub _build_values_class { return 'SyForm::Values' } |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
has loaded_values_class => ( |
43
|
|
|
|
|
|
|
is => 'lazy', |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _build_loaded_values_class { |
47
|
7
|
|
|
7
|
|
93
|
my ( $self ) = @_; |
48
|
7
|
|
|
|
|
123
|
return use_module($self->values_class); |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
sub process_values { |
52
|
11
|
|
|
11
|
0
|
62
|
my ( $self, @args ) = @_; |
53
|
11
|
|
|
|
|
81
|
return $self->create_values_by_args(@args); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub create_values_by_args { |
57
|
11
|
|
|
11
|
0
|
39
|
my ( $self, @args ) = @_; |
58
|
11
|
|
|
|
|
26
|
my %args_hash; |
59
|
11
|
|
|
|
|
17
|
my $args_count = scalar @args; |
60
|
11
|
50
|
|
|
|
66
|
if ($args_count == 1) { |
|
|
50
|
|
|
|
|
|
61
|
0
|
0
|
|
|
|
0
|
if (ref $args[0] eq 'HASH') { |
62
|
0
|
|
|
|
|
0
|
%args_hash = %{$args[0]}; |
|
0
|
|
|
|
|
0
|
|
63
|
|
|
|
|
|
|
} else { |
64
|
0
|
|
|
|
|
0
|
SyForm->throw( UnknownArgOnCreateValuesByArgs => $self,$args[0] ); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} elsif ($args_count % 2 == 0) { |
67
|
11
|
|
|
|
|
36
|
%args_hash = ( @args ); |
68
|
|
|
|
|
|
|
} else { |
69
|
0
|
|
|
|
|
0
|
SyForm->throw( OddNumberOfArgsOnCreateValuesByArgs => $self,[@args] ); |
70
|
|
|
|
|
|
|
} |
71
|
11
|
|
|
|
|
18
|
my $values; |
72
|
11
|
|
|
|
|
20
|
eval { |
73
|
11
|
|
|
|
|
42
|
my %values_args; |
74
|
11
|
|
|
|
|
306
|
for my $field ($self->fields->Values) { |
75
|
38
|
|
|
|
|
319
|
my %field_values_args = $field->values_args_by_process_args(%args_hash); |
76
|
38
|
|
|
|
|
139
|
$values_args{$_} = $field_values_args{$_} for keys %field_values_args; |
77
|
|
|
|
|
|
|
} |
78
|
11
|
|
|
|
|
56
|
$values = $self->create_values(%values_args); |
79
|
|
|
|
|
|
|
}; |
80
|
11
|
50
|
|
|
|
6740
|
SyForm->throw( UnknownErrorOnCreateValuesByArgs => $self,[@args], $@ ) if $@; |
81
|
11
|
|
|
|
|
41
|
return $values; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
sub create_values { |
85
|
11
|
|
|
11
|
0
|
46
|
my ( $self, %args ) = @_; |
86
|
11
|
|
|
|
|
23
|
my %values; |
87
|
11
|
|
|
|
|
211
|
for my $field ($self->fields->Values) { |
88
|
38
|
|
|
|
|
222
|
my $name = $field->name; |
89
|
38
|
100
|
|
|
|
121
|
$values{$name} = delete $args{$name} if exists $args{$name}; |
90
|
|
|
|
|
|
|
} |
91
|
11
|
|
|
|
|
219
|
return $self->loaded_values_class->new({ |
92
|
|
|
|
|
|
|
syform => $self, |
93
|
|
|
|
|
|
|
values => { %values }, |
94
|
|
|
|
|
|
|
%args, |
95
|
|
|
|
|
|
|
}); |
96
|
|
|
|
|
|
|
} |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
########## |
99
|
|
|
|
|
|
|
# |
100
|
|
|
|
|
|
|
# Results |
101
|
|
|
|
|
|
|
# |
102
|
|
|
|
|
|
|
########## |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
has results_class => ( |
105
|
|
|
|
|
|
|
is => 'lazy', |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub _build_results_class { |
109
|
7
|
|
|
7
|
|
89
|
my ( $self ) = @_; |
110
|
7
|
|
|
|
|
38
|
return 'SyForm::Results'; |
111
|
|
|
|
|
|
|
} |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
has loaded_results_class => ( |
114
|
|
|
|
|
|
|
is => 'lazy', |
115
|
|
|
|
|
|
|
); |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub _build_loaded_results_class { |
118
|
7
|
|
|
7
|
|
108
|
my ( $self ) = @_; |
119
|
7
|
|
|
|
|
123
|
return use_module($self->results_class); |
120
|
|
|
|
|
|
|
} |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
sub process_results { |
123
|
11
|
|
|
11
|
0
|
62
|
my ( $self, @args ) = @_; |
124
|
11
|
|
|
|
|
62
|
my $values = $self->process_values(@args); |
125
|
11
|
|
|
|
|
207
|
return $values->results; |
126
|
|
|
|
|
|
|
} |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
####### |
129
|
|
|
|
|
|
|
# |
130
|
|
|
|
|
|
|
# View |
131
|
|
|
|
|
|
|
# |
132
|
|
|
|
|
|
|
####### |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
has view_class => ( |
135
|
|
|
|
|
|
|
is => 'lazy', |
136
|
|
|
|
|
|
|
); |
137
|
|
|
|
|
|
|
|
138
|
6
|
|
|
6
|
|
90
|
sub _build_view_class { return 'SyForm::View' } |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
has loaded_view_class => ( |
141
|
|
|
|
|
|
|
is => 'lazy', |
142
|
|
|
|
|
|
|
); |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub _build_loaded_view_class { |
145
|
6
|
|
|
6
|
|
328
|
my ( $self ) = @_; |
146
|
6
|
|
|
|
|
109
|
return use_module($self->view_class); |
147
|
|
|
|
|
|
|
} |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
sub process_view { |
150
|
8
|
|
|
8
|
0
|
30
|
my ( $self, @args ) = @_; |
151
|
8
|
|
|
|
|
29
|
my $results = $self->process_results(@args); |
152
|
8
|
|
|
|
|
162
|
return $results->view; |
153
|
|
|
|
|
|
|
} |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
1; |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
__END__ |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=pod |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
=head1 NAME |
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
SyForm::Role::Process - SyForm role for processing |
164
|
|
|
|
|
|
|
|
165
|
|
|
|
|
|
|
=head1 VERSION |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
version 0.103 |
168
|
|
|
|
|
|
|
|
169
|
|
|
|
|
|
|
=head1 AUTHOR |
170
|
|
|
|
|
|
|
|
171
|
|
|
|
|
|
|
Torsten Raudssus <torsten@raudss.us> |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
174
|
|
|
|
|
|
|
|
175
|
|
|
|
|
|
|
This software is copyright (c) 2014 by Torsten Raudssus. |
176
|
|
|
|
|
|
|
|
177
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
178
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
=cut |