1DBIx::Class::Helper::ReUssuelrtSCeotn:t:rMieb(u3t)ed PerDlBIDxo:c:uCmleanstsa:t:iHoenlper::ResultSet::Me(3)
2
3
4
6 DBIx::Class::Helper::ResultSet::Me - Define predefined searches more
7 nicely
8
10 # note that this is normally a component for a ResultSet
11 package MySchema::ResultSet::Bar;
12
13 use strict;
14 use warnings;
15
16 use parent 'DBIx::Class::ResultSet';
17
18 use constant CANDY => 1;
19
20 __PACKAGE__->load_components('Helper::ResultSet::Me');
21
22 sub candy {
23 $_[0]->search({ $_[0]->me.'type' => CANDY })
24 }
25
26 sub cake {
27 $_[0]->search({ $_[0]->me('type') => CAKE })
28 }
29
30 # in code using resultset:
31 my $candy_bars = $schema->resultset('Bar')->candy;
32 my $cake_bars = $schema->resultset('Bar')->cake;
33
35 This component allows slightly nicer predefined search definition. See
36 "NOTE" in DBIx::Class::Helper::ResultSet for a nice way to apply it to
37 your entire schema.
38
39 It defines a single method that is shorter and (to most) clearer than
40 "current_source_alias" in DBIx::Class::ResultSet, which is what it uses
41 for the "me" method.
42
44 me
45 Merely returns the SQL namespace for the current search with a "." at
46 the end, allowing internal resultset methods to be defined with
47 "$self->me" instead of "$self->current_source_alias . q(.)". Also, if
48 you pass it a single argument it will append that to the returned
49 string.
50
52 Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
53
55 This software is copyright (c) 2020 by Arthur Axel "fREW" Schmidt.
56
57 This is free software; you can redistribute it and/or modify it under
58 the same terms as the Perl 5 programming language system itself.
59
60
61
62perl v5.36.0 2023-01-D2B0Ix::Class::Helper::ResultSet::Me(3)