line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Helper::ResultSet::Me; |
2
|
|
|
|
|
|
|
$DBIx::Class::Helper::ResultSet::Me::VERSION = '2.036000'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Define predefined searches more nicely |
4
|
|
|
|
|
|
|
|
5
|
56
|
|
|
56
|
|
25972
|
use strict; |
|
56
|
|
|
|
|
152
|
|
|
56
|
|
|
|
|
1572
|
|
6
|
56
|
|
|
56
|
|
287
|
use warnings; |
|
56
|
|
|
|
|
109
|
|
|
56
|
|
|
|
|
1574
|
|
7
|
|
|
|
|
|
|
|
8
|
56
|
|
|
56
|
|
280
|
use parent 'DBIx::Class::ResultSet'; |
|
56
|
|
|
|
|
106
|
|
|
56
|
|
|
|
|
280
|
|
9
|
|
|
|
|
|
|
|
10
|
7
|
|
100
|
7
|
1
|
858
|
sub me { join('.', shift->current_source_alias, shift || q{}) } |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
1; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
__END__ |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
=pod |
17
|
|
|
|
|
|
|
|
18
|
|
|
|
|
|
|
=head1 NAME |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
DBIx::Class::Helper::ResultSet::Me - Define predefined searches more nicely |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
=head1 SYNOPSIS |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
# note that this is normally a component for a ResultSet |
25
|
|
|
|
|
|
|
package MySchema::ResultSet::Bar; |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
use strict; |
28
|
|
|
|
|
|
|
use warnings; |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
use parent 'DBIx::Class::ResultSet'; |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
use constant CANDY => 1; |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->load_components('Helper::ResultSet::Me'); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub candy { |
37
|
|
|
|
|
|
|
$_[0]->search({ $_[0]->me.'type' => CANDY }) |
38
|
|
|
|
|
|
|
} |
39
|
|
|
|
|
|
|
|
40
|
|
|
|
|
|
|
sub cake { |
41
|
|
|
|
|
|
|
$_[0]->search({ $_[0]->me('type') => CAKE }) |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
# in code using resultset: |
45
|
|
|
|
|
|
|
my $candy_bars = $schema->resultset('Bar')->candy; |
46
|
|
|
|
|
|
|
my $cake_bars = $schema->resultset('Bar')->cake; |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=head1 DESCRIPTION |
49
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
This component allows slightly nicer predefined search definition. See |
51
|
|
|
|
|
|
|
L<DBIx::Class::Helper::ResultSet/NOTE> for a nice way to apply it to your |
52
|
|
|
|
|
|
|
entire schema. |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
It defines a single method that is shorter and (to most) clearer than |
55
|
|
|
|
|
|
|
L<DBIx::Class::ResultSet/current_source_alias>, which is what it uses |
56
|
|
|
|
|
|
|
for the L</me> method. |
57
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
=head1 METHODS |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
=head2 me |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
Merely returns the SQL namespace for the current search with a C<.> at the end, |
63
|
|
|
|
|
|
|
allowing internal resultset methods to be defined with C<< $self->me >> instead |
64
|
|
|
|
|
|
|
of C<< $self->current_source_alias . q(.) >>. Also, if you pass it a single |
65
|
|
|
|
|
|
|
argument it will append that to the returned string. |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
=head1 AUTHOR |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
72
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
This software is copyright (c) 2020 by Arthur Axel "fREW" Schmidt. |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
76
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
=cut |