line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package #hide |
2
|
|
|
|
|
|
|
My::User; |
3
|
2
|
|
|
2
|
|
8
|
use base qw(My); |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
102
|
|
4
|
2
|
|
|
2
|
|
6
|
use strict; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
36
|
|
5
|
2
|
|
|
2
|
|
4
|
use warnings; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
33
|
|
6
|
2
|
|
|
2
|
|
6
|
use utf8; |
|
2
|
|
|
|
|
2
|
|
|
2
|
|
|
|
|
5
|
|
7
|
|
|
|
|
|
|
|
8
|
14
|
|
|
14
|
1
|
69
|
sub TABLE {'users'} |
9
|
9
|
|
|
9
|
1
|
35
|
sub COLUMNS { [qw(id group_id login_name login_password disabled)] } |
10
|
5
|
|
|
5
|
1
|
19
|
sub WHERE { {disabled => 1} } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
#See Params::Check |
13
|
|
|
|
|
|
|
my $_CHECKS = { |
14
|
|
|
|
|
|
|
id => {allow => qr/^\d+$/x}, |
15
|
|
|
|
|
|
|
group_id => {allow => qr/^\d+$/x, default => 1}, |
16
|
|
|
|
|
|
|
disabled => { |
17
|
|
|
|
|
|
|
default => 1, |
18
|
|
|
|
|
|
|
allow => sub { |
19
|
|
|
|
|
|
|
return $_[0] =~ /^[01]$/x; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
}, |
22
|
2
|
|
|
2
|
|
281
|
login_name => {allow => qr/^\p{IsAlnum}{4,12}$/x}, |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
22
|
|
23
|
|
|
|
|
|
|
login_password => { |
24
|
|
|
|
|
|
|
required => 1, |
25
|
|
|
|
|
|
|
allow => sub { $_[0] =~ /^[\w\W]{8,20}$/x; } |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
#... |
29
|
|
|
|
|
|
|
}; |
30
|
41
|
|
|
41
|
1
|
503
|
sub CHECKS {$_CHECKS} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
sub id { |
33
|
13
|
|
|
13
|
0
|
268
|
my ($self, $value) = @_; |
34
|
13
|
100
|
|
|
|
20
|
if (defined $value) { #setting value |
35
|
1
|
|
|
|
|
7
|
$self->{data}{id} = $self->_check(id => $value); |
36
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
#make it chainable |
38
|
0
|
|
|
|
|
0
|
return $self; |
39
|
|
|
|
|
|
|
} |
40
|
12
|
|
66
|
|
|
51
|
$self->{data}{id} //= $self->CHECKS->{id}{default}; #getting value |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
1; |