line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package File::DataClass::ResultSource; |
2
|
|
|
|
|
|
|
|
3
|
3
|
|
|
3
|
|
12
|
use namespace::autoclean; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
17
|
|
4
|
|
|
|
|
|
|
|
5
|
3
|
|
|
3
|
|
189
|
use File::DataClass::Constants qw( FALSE NUL TRUE ); |
|
3
|
|
|
|
|
4
|
|
|
3
|
|
|
|
|
115
|
|
6
|
3
|
|
|
3
|
|
1154
|
use File::DataClass::ResultSet; |
|
3
|
|
|
|
|
7
|
|
|
3
|
|
|
|
|
139
|
|
7
|
3
|
|
|
|
|
24
|
use File::DataClass::Types qw( ArrayRef ClassName HashRef |
8
|
3
|
|
|
3
|
|
19
|
Object SimpleStr Str ); |
|
3
|
|
|
|
|
3
|
|
9
|
3
|
|
|
3
|
|
2400
|
use Moo; |
|
3
|
|
|
|
|
3
|
|
|
3
|
|
|
|
|
14
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# Private functions |
12
|
|
|
|
|
|
|
my $_build_attributes = sub { |
13
|
1
|
|
|
1
|
|
646
|
my $self = shift; my $attr = {}; |
|
1
|
|
|
|
|
2
|
|
14
|
|
|
|
|
|
|
|
15
|
1
|
|
|
|
|
2
|
$attr->{ $_ } = TRUE for (@{ $self->attributes }); |
|
1
|
|
|
|
|
6
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
|
|
14
|
return $attr; |
18
|
|
|
|
|
|
|
}; |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
# Public attributes |
21
|
|
|
|
|
|
|
has 'attributes' => is => 'ro', isa => ArrayRef[Str], |
22
|
|
|
|
|
|
|
required => TRUE; |
23
|
|
|
|
|
|
|
|
24
|
4
|
|
|
4
|
|
6466
|
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
|
|
3877
|
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
|
|
320
|
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
|
17
|
return @{ $_[ 0 ]->attributes }; |
|
1
|
|
|
|
|
10
|
|
47
|
|
|
|
|
|
|
} |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
sub has_column { |
50
|
3
|
|
100
|
3
|
1
|
12
|
my $key = $_[ 1 ] // '_invalid_key_'; |
51
|
|
|
|
|
|
|
|
52
|
3
|
100
|
|
|
|
46
|
return exists $_[ 0 ]->_attributes->{ $key } ? TRUE : FALSE; |
53
|
|
|
|
|
|
|
} |
54
|
|
|
|
|
|
|
|
55
|
|
|
|
|
|
|
sub resultset { |
56
|
20
|
|
|
20
|
1
|
25
|
my $self = shift; |
57
|
|
|
|
|
|
|
|
58
|
20
|
|
|
|
|
31
|
my $attrs = { %{ $self->resultset_attributes }, result_source => $self }; |
|
20
|
|
|
|
|
75
|
|
59
|
|
|
|
|
|
|
|
60
|
20
|
|
|
|
|
296
|
return $self->resultset_class->new( $attrs ); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
1; |
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
__END__ |