line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Form::Tiny::Hook; |
2
|
|
|
|
|
|
|
$Form::Tiny::Hook::VERSION = '2.19'; |
3
|
51
|
|
|
51
|
|
725
|
use v5.10; |
|
51
|
|
|
|
|
228
|
|
4
|
51
|
|
|
51
|
|
370
|
use strict; |
|
51
|
|
|
|
|
144
|
|
|
51
|
|
|
|
|
1146
|
|
5
|
51
|
|
|
51
|
|
367
|
use warnings; |
|
51
|
|
|
|
|
164
|
|
|
51
|
|
|
|
|
1588
|
|
6
|
51
|
|
|
51
|
|
299
|
use Moo; |
|
51
|
|
|
|
|
145
|
|
|
51
|
|
|
|
|
429
|
|
7
|
51
|
|
|
51
|
|
20676
|
use Types::Standard qw(Enum CodeRef Bool); |
|
51
|
|
|
|
|
291
|
|
|
51
|
|
|
|
|
547
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
use constant { |
10
|
51
|
|
|
|
|
17853
|
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
|
|
99032
|
}; |
|
51
|
|
|
|
|
164
|
|
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
|
485
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
# whether a hook type will modify the input data |
50
|
|
|
|
|
|
|
# with return statements |
51
|
265
|
|
|
|
|
480
|
my %modifying = map { $_ => 1 } ( |
|
530
|
|
|
|
|
1438
|
|
52
|
|
|
|
|
|
|
HOOK_BEFORE_MANGLE, |
53
|
|
|
|
|
|
|
HOOK_REFORMAT |
54
|
|
|
|
|
|
|
); |
55
|
265
|
|
|
|
|
1521
|
return exists $modifying{$self->hook}; |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
} |
58
|
|
|
|
|
|
|
|
59
|
|
|
|
|
|
|
1; |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
__END__ |