line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Hook; |
2
|
|
|
|
|
|
|
$Form::Tiny::Hook::VERSION = '2.20'; |
3
|
51
|
|
|
51
|
|
693
|
use v5.10; |
|
51
|
|
|
|
|
199
|
|
4
|
51
|
|
|
51
|
|
316
|
use strict; |
|
51
|
|
|
|
|
157
|
|
|
51
|
|
|
|
|
1116
|
|
5
|
51
|
|
|
51
|
|
258
|
use warnings; |
|
51
|
|
|
|
|
131
|
|
|
51
|
|
|
|
|
1543
|
|
6
|
51
|
|
|
51
|
|
337
|
use Moo; |
|
51
|
|
|
|
|
125
|
|
|
51
|
|
|
|
|
414
|
|
7
|
51
|
|
|
51
|
|
19697
|
use Types::Standard qw(Enum CodeRef Bool); |
|
51
|
|
|
|
|
222
|
|
|
51
|
|
|
|
|
509
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant { |
10
|
51
|
|
|
|
|
17529
|
HOOK_REFORMAT => 'reformat', |
11
|
|
|
|
|
|
|
HOOK_BEFORE_MANGLE => 'before_mangle', |
12
|
|
|
|
|
|
|
HOOK_BEFORE_VALIDATE => 'before_validate', |
13
|
|
|
|
|
|
|
HOOK_AFTER_VALIDATE => 'after_validate', |
14
|
|
|
|
|
|
|
HOOK_CLEANUP => 'cleanup', |
15
|
|
|
|
|
|
|
HOOK_AFTER_ERROR => 'after_error', |
16
|
51
|
|
|
51
|
|
97265
|
}; |
|
51
|
|
|
|
|
155
|
|
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
my @hooks = ( |
19
|
|
|
|
|
|
|
HOOK_REFORMAT, |
20
|
|
|
|
|
|
|
HOOK_BEFORE_MANGLE, |
21
|
|
|
|
|
|
|
HOOK_BEFORE_VALIDATE, |
22
|
|
|
|
|
|
|
HOOK_AFTER_VALIDATE, |
23
|
|
|
|
|
|
|
HOOK_CLEANUP, |
24
|
|
|
|
|
|
|
HOOK_AFTER_ERROR, |
25
|
|
|
|
|
|
|
); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
has 'hook' => ( |
28
|
|
|
|
|
|
|
is => 'ro', |
29
|
|
|
|
|
|
|
isa => Enum [@hooks], |
30
|
|
|
|
|
|
|
required => 1, |
31
|
|
|
|
|
|
|
); |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
has 'code' => ( |
34
|
|
|
|
|
|
|
is => 'ro', |
35
|
|
|
|
|
|
|
isa => CodeRef, |
36
|
|
|
|
|
|
|
required => 1, |
37
|
|
|
|
|
|
|
); |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has 'inherited' => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => Bool, |
42
|
|
|
|
|
|
|
default => sub { 1 }, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
sub is_modifying |
46
|
|
|
|
|
|
|
{ |
47
|
265
|
|
|
265
|
1
|
483
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# whether a hook type will modify the input data |
50
|
|
|
|
|
|
|
# with return statements |
51
|
265
|
|
|
|
|
486
|
my %modifying = map { $_ => 1 } ( |
|
530
|
|
|
|
|
1387
|
|
52
|
|
|
|
|
|
|
HOOK_BEFORE_MANGLE, |
53
|
|
|
|
|
|
|
HOOK_REFORMAT |
54
|
|
|
|
|
|
|
); |
55
|
265
|
|
|
|
|
1482
|
return exists $modifying{$self->hook}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |