line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package HTML::Shakan::Field; |
2
|
22
|
|
|
22
|
|
11877
|
use strict; |
|
22
|
|
|
|
|
40
|
|
|
22
|
|
|
|
|
700
|
|
3
|
22
|
|
|
22
|
|
101
|
use warnings; |
|
22
|
|
|
|
|
33
|
|
|
22
|
|
|
|
|
585
|
|
4
|
22
|
|
|
22
|
|
102
|
use Mouse; |
|
22
|
|
|
|
|
34
|
|
|
22
|
|
|
|
|
101
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
has id => ( |
7
|
|
|
|
|
|
|
is => 'rw', |
8
|
|
|
|
|
|
|
isa => 'Str', |
9
|
|
|
|
|
|
|
trigger => sub { |
10
|
|
|
|
|
|
|
my ($self, $id) = @_; |
11
|
|
|
|
|
|
|
$self->{attr}->{id} = $id; |
12
|
|
|
|
|
|
|
}, |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
has name => ( |
16
|
|
|
|
|
|
|
is => 'ro', |
17
|
|
|
|
|
|
|
isa => 'Str', |
18
|
|
|
|
|
|
|
required => 1, |
19
|
|
|
|
|
|
|
trigger => sub { |
20
|
|
|
|
|
|
|
my ( $self, $name ) = @_; |
21
|
|
|
|
|
|
|
$self->{attr}->{name} = $name; |
22
|
|
|
|
|
|
|
}, |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
has value => ( |
26
|
|
|
|
|
|
|
is => 'rw', |
27
|
|
|
|
|
|
|
isa => 'Str', |
28
|
|
|
|
|
|
|
required => 0, |
29
|
|
|
|
|
|
|
trigger => sub { |
30
|
|
|
|
|
|
|
my ( $self, $value ) = @_; |
31
|
|
|
|
|
|
|
$self->{attr}->{value} = $value; |
32
|
|
|
|
|
|
|
}, |
33
|
|
|
|
|
|
|
); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has filters => ( |
36
|
|
|
|
|
|
|
is => 'rw', |
37
|
|
|
|
|
|
|
isa => 'ArrayRef[Str]', |
38
|
|
|
|
|
|
|
default => sub { +[] } |
39
|
|
|
|
|
|
|
); |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has widget => ( |
42
|
|
|
|
|
|
|
is => 'ro', |
43
|
|
|
|
|
|
|
isa => 'Str', |
44
|
|
|
|
|
|
|
required => 1, |
45
|
|
|
|
|
|
|
); |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
has attr => ( |
48
|
|
|
|
|
|
|
is => 'ro', |
49
|
|
|
|
|
|
|
isa => 'HashRef', |
50
|
|
|
|
|
|
|
lazy => 1, |
51
|
|
|
|
|
|
|
default => sub { |
52
|
|
|
|
|
|
|
+{} |
53
|
|
|
|
|
|
|
}, |
54
|
|
|
|
|
|
|
); |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
has label => ( |
57
|
|
|
|
|
|
|
is => 'ro', |
58
|
|
|
|
|
|
|
isa => 'Str', |
59
|
|
|
|
|
|
|
lazy => 1, |
60
|
|
|
|
|
|
|
default => sub { shift->name } |
61
|
|
|
|
|
|
|
); |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
has required => ( |
64
|
|
|
|
|
|
|
is => 'ro', |
65
|
|
|
|
|
|
|
isa => 'Bool', |
66
|
|
|
|
|
|
|
default => 0, |
67
|
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
has inflator => ( |
70
|
|
|
|
|
|
|
is => 'ro', |
71
|
|
|
|
|
|
|
isa => 'Object', |
72
|
|
|
|
|
|
|
); |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
has custom_validation => ( |
75
|
|
|
|
|
|
|
is => 'ro', |
76
|
|
|
|
|
|
|
isa => 'CodeRef', |
77
|
|
|
|
|
|
|
); |
78
|
|
|
|
|
|
|
|
79
|
|
|
|
|
|
|
has constraints => ( |
80
|
|
|
|
|
|
|
is => 'ro', |
81
|
|
|
|
|
|
|
isa => 'ArrayRef', |
82
|
|
|
|
|
|
|
default => sub { +[] }, |
83
|
|
|
|
|
|
|
); |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
sub add_constraint { |
86
|
15
|
|
|
15
|
0
|
36
|
my ($self, @constraint) = @_; |
87
|
15
|
|
|
|
|
23
|
push @{$self->{constraints}}, @constraint; |
|
15
|
|
|
|
|
39
|
|
88
|
15
|
|
|
|
|
108
|
$self; # method chain |
89
|
|
|
|
|
|
|
} |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
has complex_constraints => ( |
92
|
|
|
|
|
|
|
is => 'ro', |
93
|
|
|
|
|
|
|
isa => 'ArrayRef', |
94
|
|
|
|
|
|
|
default => sub { +[] }, |
95
|
|
|
|
|
|
|
); |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
sub add_complex_constraint { |
98
|
2
|
|
|
2
|
0
|
5
|
my ($self, @constraints) = @_; |
99
|
2
|
|
|
|
|
2
|
push @{$self->{complex_constraints}}, @constraints; |
|
2
|
|
|
|
|
8
|
|
100
|
2
|
|
|
|
|
4
|
$self; # method chain |
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
sub get_constraints { |
104
|
62
|
|
|
62
|
0
|
175
|
my $self = shift; |
105
|
|
|
|
|
|
|
|
106
|
62
|
|
|
|
|
85
|
my @rule = @{$self->{constraints}}; |
|
62
|
|
|
|
|
161
|
|
107
|
62
|
100
|
|
|
|
341
|
if ($self->required) { |
108
|
15
|
|
|
|
|
29
|
push @rule, 'NOT_NULL'; |
109
|
|
|
|
|
|
|
} |
110
|
|
|
|
|
|
|
return ( |
111
|
62
|
|
|
|
|
401
|
$self->name => \@rule, |
112
|
62
|
|
|
|
|
165
|
@{ $self->complex_constraints }, |
113
|
|
|
|
|
|
|
); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
22
|
|
|
22
|
|
19293
|
no Mouse; |
|
22
|
|
|
|
|
84
|
|
|
22
|
|
|
|
|
144
|
|
117
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
118
|
|
|
|
|
|
|
__END__ |