1package DBIx::Class::Helper::ResultSet::Me; 2$DBIx::Class::Helper::ResultSet::Me::VERSION = '2.036000'; 3# ABSTRACT: Define predefined searches more nicely 4 5use strict; 6use warnings; 7 8use parent 'DBIx::Class::ResultSet'; 9 10sub me { join('.', shift->current_source_alias, shift || q{}) } 11 121; 13 14__END__ 15 16=pod 17 18=head1 NAME 19 20DBIx::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 50This component allows slightly nicer predefined search definition. See 51L<DBIx::Class::Helper::ResultSet/NOTE> for a nice way to apply it to your 52entire schema. 53 54It defines a single method that is shorter and (to most) clearer than 55L<DBIx::Class::ResultSet/current_source_alias>, which is what it uses 56for the L</me> method. 57 58=head1 METHODS 59 60=head2 me 61 62Merely returns the SQL namespace for the current search with a C<.> at the end, 63allowing internal resultset methods to be defined with C<< $self->me >> instead 64of C<< $self->current_source_alias . q(.) >>. Also, if you pass it a single 65argument it will append that to the returned string. 66 67=head1 AUTHOR 68 69Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com> 70 71=head1 COPYRIGHT AND LICENSE 72 73This software is copyright (c) 2020 by Arthur Axel "fREW" Schmidt. 74 75This is free software; you can redistribute it and/or modify it under 76the same terms as the Perl 5 programming language system itself. 77 78=cut 79