line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Catalyst::Controller::DBIC::API::JoinBuilder; |
2
|
|
|
|
|
|
|
$Catalyst::Controller::DBIC::API::JoinBuilder::VERSION = '2.008001'; |
3
|
|
|
|
|
|
|
#ABSTRACT: Provides a helper class to automatically keep track of joins in complex searches |
4
|
16
|
|
|
16
|
|
126
|
use Moose; |
|
16
|
|
|
|
|
48
|
|
|
16
|
|
|
|
|
133
|
|
5
|
16
|
|
|
16
|
|
79823
|
use MooseX::Types::Moose(':all'); |
|
16
|
|
|
|
|
81
|
|
|
16
|
|
|
|
|
288
|
|
6
|
16
|
|
|
16
|
|
137472
|
use Catalyst::Controller::DBIC::API::Types(':all'); |
|
16
|
|
|
|
|
46
|
|
|
16
|
|
|
|
|
198
|
|
7
|
16
|
|
|
16
|
|
79828
|
use namespace::autoclean; |
|
16
|
|
|
|
|
49
|
|
|
16
|
|
|
|
|
140
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
has parent => ( |
11
|
|
|
|
|
|
|
is => 'ro', |
12
|
|
|
|
|
|
|
isa => JoinBuilder, |
13
|
|
|
|
|
|
|
predicate => 'has_parent', |
14
|
|
|
|
|
|
|
weak_ref => 1, |
15
|
|
|
|
|
|
|
trigger => sub { my ( $self, $new ) = @_; $new->add_child($self); }, |
16
|
|
|
|
|
|
|
); |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
|
19
|
|
|
|
|
|
|
has children => ( |
20
|
|
|
|
|
|
|
is => 'ro', |
21
|
|
|
|
|
|
|
isa => ArrayRef [JoinBuilder], |
22
|
|
|
|
|
|
|
traits => ['Array'], |
23
|
|
|
|
|
|
|
default => sub { [] }, |
24
|
|
|
|
|
|
|
handles => { |
25
|
|
|
|
|
|
|
all_children => 'elements', |
26
|
|
|
|
|
|
|
has_children => 'count', |
27
|
|
|
|
|
|
|
add_child => 'push', |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
); |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
has joins => ( |
33
|
|
|
|
|
|
|
is => 'ro', |
34
|
|
|
|
|
|
|
isa => HashRef, |
35
|
|
|
|
|
|
|
lazy_build => 1, |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has name => ( |
40
|
|
|
|
|
|
|
is => 'ro', |
41
|
|
|
|
|
|
|
isa => Str, |
42
|
|
|
|
|
|
|
required => 1, |
43
|
|
|
|
|
|
|
); |
44
|
|
|
|
|
|
|
|
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub _build_joins { |
47
|
54
|
|
|
54
|
|
168
|
my ($self) = @_; |
48
|
|
|
|
|
|
|
|
49
|
54
|
|
|
|
|
125
|
my $parent; |
50
|
54
|
|
|
|
|
2071
|
while ( my $found = $self->parent ) { |
51
|
0
|
0
|
|
|
|
0
|
if ( $found->has_parent ) { |
52
|
0
|
|
|
|
|
0
|
$self = $found; |
53
|
0
|
|
|
|
|
0
|
next; |
54
|
|
|
|
|
|
|
} |
55
|
0
|
|
|
|
|
0
|
$parent = $found; |
56
|
|
|
|
|
|
|
} |
57
|
|
|
|
|
|
|
|
58
|
54
|
|
|
|
|
119
|
my $builder; |
59
|
|
|
|
|
|
|
$builder = sub { |
60
|
70
|
|
|
70
|
|
188
|
my ($node) = @_; |
61
|
70
|
|
|
|
|
145
|
my $foo = {}; |
62
|
70
|
|
|
|
|
3274
|
map { $foo->{ $_->name } = $builder->($_) } $node->all_children; |
|
16
|
|
|
|
|
70
|
|
63
|
70
|
|
|
|
|
2618
|
return $foo; |
64
|
54
|
|
|
|
|
409
|
}; |
65
|
|
|
|
|
|
|
|
66
|
54
|
|
33
|
|
|
344
|
return $builder->( $parent || $self ); |
67
|
|
|
|
|
|
|
} |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
1; |
71
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
__END__ |
73
|
|
|
|
|
|
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Catalyst::Controller::DBIC::API::JoinBuilder - Provides a helper class to automatically keep track of joins in complex searches |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
version 2.008001 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 DESCRIPTION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
JoinBuilder is used to keep track of joins automagically for complex searches. |
87
|
|
|
|
|
|
|
It accomplishes this by building a simple tree of parents and children and then |
88
|
|
|
|
|
|
|
recursively drilling into the tree to produce a useable join attribute for |
89
|
|
|
|
|
|
|
search. |
90
|
|
|
|
|
|
|
|
91
|
|
|
|
|
|
|
=head1 PUBLIC_ATTRIBUTES |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head2 parent |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Stores the direct ascendant in the datastructure that represents the join. |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head2 children |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
Stores the immediate descendants in the datastructure that represents the join. |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Handles the following methods: |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
all_children => 'elements' |
104
|
|
|
|
|
|
|
has_children => 'count' |
105
|
|
|
|
|
|
|
add_child => 'push' |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
=head2 joins |
108
|
|
|
|
|
|
|
|
109
|
|
|
|
|
|
|
Holds the cached, generated join datastructure. |
110
|
|
|
|
|
|
|
|
111
|
|
|
|
|
|
|
=head2 name |
112
|
|
|
|
|
|
|
|
113
|
|
|
|
|
|
|
Sets the key for this level in the generated hash. |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
=head1 PRIVATE_METHODS |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
=head2 _build_joins |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
Finds the top parent in the structure and then recursively iterates the children |
120
|
|
|
|
|
|
|
building out the join datastructure. |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 AUTHORS |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
=over 4 |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=item * |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
Nicholas Perez <nperez@cpan.org> |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
=item * |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
Luke Saunders <luke.saunders@gmail.com> |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=item * |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
Alexander Hartmaier <abraxxa@cpan.org> |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
=item * |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
Florian Ragwitz <rafl@debian.org> |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
=item * |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
Oleg Kostyuk <cub.uanic@gmail.com> |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
=item * |
147
|
|
|
|
|
|
|
|
148
|
|
|
|
|
|
|
Samuel Kaufman <sam@socialflow.com> |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
=back |
151
|
|
|
|
|
|
|
|
152
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
153
|
|
|
|
|
|
|
|
154
|
|
|
|
|
|
|
This software is copyright (c) 2019 by Luke Saunders, Nicholas Perez, Alexander Hartmaier, et al. |
155
|
|
|
|
|
|
|
|
156
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
157
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
=cut |