line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::DataClass::ResultSource; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
16
|
use namespace::autoclean; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
18
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
220
|
use File::DataClass::Constants qw( FALSE NUL TRUE ); |
|
3
|
|
|
|
|
12
|
|
|
3
|
|
|
|
|
147
|
|
6
|
3
|
|
|
3
|
|
1291
|
use File::DataClass::ResultSet; |
|
3
|
|
|
|
|
6
|
|
|
3
|
|
|
|
|
113
|
|
7
|
3
|
|
|
|
|
25
|
use File::DataClass::Types qw( ArrayRef ClassName HashRef |
8
|
3
|
|
|
3
|
|
23
|
Object SimpleStr Str ); |
|
3
|
|
|
|
|
3
|
|
9
|
3
|
|
|
3
|
|
2571
|
use Moo; |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
12
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Private functions |
12
|
|
|
|
|
|
|
my $_build_attributes = sub { |
13
|
1
|
|
|
1
|
|
9
|
my $self = shift; my $attr = {}; |
|
1
|
|
|
|
|
2
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
2
|
$attr->{ $_ } = TRUE for (@{ $self->attributes }); |
|
1
|
|
|
|
|
6
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
13
|
return $attr; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Public attributes |
21
|
|
|
|
|
|
|
has 'attributes' => is => 'ro', isa => ArrayRef[Str], |
22
|
|
|
|
|
|
|
required => TRUE; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
4
|
|
6939
|
has 'defaults' => is => 'ro', isa => HashRef, builder => sub { {} }; |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
has 'name' => is => 'ro', isa => SimpleStr, required => TRUE; |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
has 'label_attr' => is => 'ro', isa => SimpleStr, default => NUL; |
29
|
|
|
|
|
|
|
|
30
|
6
|
|
|
6
|
|
3709
|
has 'resultset_attributes' => is => 'ro', isa => HashRef, builder => sub { {} }; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has 'resultset_class' => is => 'ro', isa => ClassName, |
33
|
|
|
|
|
|
|
default => 'File::DataClass::ResultSet'; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
has 'schema' => is => 'ro', isa => Object, |
36
|
|
|
|
|
|
|
handles => [ 'path', 'storage' ], |
37
|
|
|
|
|
|
|
required => TRUE, weak_ref => TRUE; |
38
|
|
|
|
|
|
|
|
39
|
5
|
|
|
5
|
|
368
|
has 'types' => is => 'ro', isa => HashRef, builder => sub { {} }; |
40
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
has '_attributes' => is => 'lazy', isa => HashRef, |
42
|
|
|
|
|
|
|
builder => $_build_attributes, init_arg => undef; |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# Public methods |
45
|
|
|
|
|
|
|
sub columns { |
46
|
1
|
|
|
1
|
1
|
11
|
return @{ $_[ 0 ]->attributes }; |
|
1
|
|
|
|
|
7
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub has_column { |
50
|
3
|
|
100
|
3
|
1
|
11
|
my $key = $_[ 1 ] // '_invalid_key_'; |
51
|
|
|
|
|
|
|
|
52
|
3
|
100
|
|
|
|
57
|
return exists $_[ 0 ]->_attributes->{ $key } ? TRUE : FALSE; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub resultset { |
56
|
20
|
|
|
20
|
1
|
23
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
20
|
|
|
|
|
22
|
my $attrs = { %{ $self->resultset_attributes }, result_source => $self }; |
|
20
|
|
|
|
|
70
|
|
59
|
|
|
|
|
|
|
|
60
|
20
|
|
|
|
|
283
|
return $self->resultset_class->new( $attrs ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |