Helper/ResultSet/Util.pm

filter: Statementstmt 100% 15 / 15 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 100% 20 / 20 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Helper/ResultSet/Shortcut/Search/Null.pm ↑ Summary Helper/Row/CleanResultSet.pm »
1 package DBIx::Class::Helper::ResultSet::Util;
2 54 $DBIx::Class::Helper::ResultSet::Util::VERSION = '2.033001';
3 54 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 54 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 # ABSTRACT: Helper utilities for DBIx::Class ResultSets
7  
8 54 use Sub::Exporter::Progressive -setup => {
9 exports => [
10 qw( correlate ),
11 ],
12 54 ▶};
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub correlate {
15 2 ▶ my ($rs, $rel) = @_;
Subroutine correlate: called CC=1 SCAR=0.0
Pod documented
16  
17 2 my $source = $rs->result_source;
18 2 my $rel_info = $source->relationship_info($rel);
19  
20 return $source->related_source($rel)->resultset
21 ->search(scalar $source->_resolve_condition(
22 $rel_info->{cond},
23 2 "${rel}_alias",
24 $rs->current_source_alias,
25 $rel
26 ), {
27 alias => "${rel}_alias",
28 })
29 }
30  
31 54 1;
32  
33 __END__
34  
35 =pod
36  
37 =head1 NAME
38  
39 DBIx::Class::Helper::ResultSet::Util - Helper utilities for DBIx::Class ResultSets
40  
41 =head1 DESCRIPTION
42  
43 These functions will slowly become the core implementations of many existing
44 components. The reason for this is that often you are not able to or unwilling
45 to add a component to an object, as adding the component fundamentally changes
46 the object. If instead you merely act on the object with a subroutine you are
47 not committing as seriously.
48  
49 =head1 EXPORTS
50  
51 =head2 correlate
52  
53 correlate($author_rs, 'books')
54  
55 This function allows you to correlate a resultset with one of it's
56 relationships. It takes the ResultSet and relationship name as arguments. See
57 L<DBIx::Class::Helper::ResultSet::CorrelateRelationship/SYNOPSIS> for an in
58 depth example.
59  
60 =head1 AUTHOR
61  
62 Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
63  
64 =head1 COPYRIGHT AND LICENSE
65  
66 This software is copyright (c) 2016 by Arthur Axel "fREW" Schmidt.
67  
68 This is free software; you can redistribute it and/or modify it under
69 the same terms as the Perl 5 programming language system itself.
70  
71 =cut
« Helper/ResultSet/Shortcut/Search/Null.pm ↑ Summary Helper/Row/CleanResultSet.pm »