Smooth/Helper/Row/JoinTable.pm

filter: Statementstmt 100% 53 / 53 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 12 / 12 Podpod 0.0% 0 / 1 totaltotal 98.4% 65 / 66 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« Smooth/Lookup/DateTime/year.pm ↑ Summary Smooth.pm »
1 3 ▶use 5.20.0;
Subroutine BEGIN: called CC=1 SCAR=0.0
2 3 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 3 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 package DBIx::Class::Smooth::Helper::Row::JoinTable;
6  
7 # ABSTRACT: Short intro
8 3 our $AUTHORITY = 'cpan:CSSON'; # AUTHORITY
9 3 our $VERSION = '0.0104';
10  
11 3 ▶use parent 'DBIx::Class::Row';
Subroutine BEGIN: called CC=1 SCAR=0.0
12 3 ▶use String::CamelCase;
Subroutine BEGIN: called CC=1 SCAR=0.0
13 3 ▶use Module::Loader;
Subroutine BEGIN: called CC=1 SCAR=0.0
14 3 ▶use Syntax::Keyword::Try;
Subroutine BEGIN: called CC=1 SCAR=0.0
15 3 ▶use Carp qw/croak/;
Subroutine BEGIN: called CC=1 SCAR=0.0
16 3 ▶use DBIx::Class::Candy::Exports;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 3 ▶use DBIx::Class::Smooth::Helper::Util qw/result_source_to_class result_source_to_relation_name clean_source_name/;
Subroutine BEGIN: called CC=1 SCAR=0.0
18  
19 3 ▶use experimental qw/postderef signatures/;
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 3 export_methods [qw/
22 join_table
23 /];
24  
25 3 state $module_loader = Module::Loader->new;
26  
27 ▶sub join_table($self, $left_source, $right_source) {
Subroutine join_table: called CC=1 SCAR=0.0
Pod undocumented
28  
29 2 my $left_class = result_source_to_class($self, $left_source);
30 2 my $right_class = result_source_to_class($self, $right_source);
31 2 my $via_class = $self;
32  
33 2 my $to_via_relation_name = result_source_to_relation_name($via_class, 1);
34 2 my $via_to_right_relation_name = result_source_to_relation_name($right_source, 0);
35 2 my $left_to_right_relation_name = result_source_to_relation_name($right_source, 1);
36 2 my $via_to_left_relation_name = result_source_to_relation_name($left_source, 0);
37 2 my $right_to_left_relation_name = result_source_to_relation_name($left_source, 1);
38  
39 2 my $left_column_name_in_via = $via_to_left_relation_name . '_id';
40 2 my $right_column_name_in_via = $via_to_right_relation_name . '_id';
41  
42 2 $via_class->primary_belongs($left_source, { _smooth_foreign_key => 1 });
43 2 $via_class->primary_belongs($right_source, { _smooth_foreign_key => 1 });
44  
45 2 $module_loader->load($left_class);
46 2 $module_loader->load($right_class);
47  
48 2 $left_class->many_to_many($left_to_right_relation_name, $to_via_relation_name, $via_to_right_relation_name);
49 2 $right_class->many_to_many($right_to_left_relation_name, $to_via_relation_name, $via_to_left_relation_name);
50 }
51  
52 3 1;
53  
54 __END__
55  
56 =pod
57  
58 =encoding UTF-8
59  
60 =head1 NAME
61  
62 DBIx::Class::Smooth::Helper::Row::JoinTable - Short intro
63  
64 =head1 VERSION
65  
66 Version 0.0104, released 2020-08-30.
67  
68 =head1 SOURCE
69  
70 L<https://github.com/Csson/p5-DBIx-Class-Smooth>
71  
72 =head1 HOMEPAGE
73  
74 L<https://metacpan.org/release/DBIx-Class-Smooth>
75  
76 =head1 AUTHOR
77  
78 Erik Carlsson <info@code301.com>
79  
80 =head1 COPYRIGHT AND LICENSE
81  
82 This software is copyright (c) 2018 by Erik Carlsson.
83  
84 This is free software; you can redistribute it and/or modify it under
85 the same terms as the Perl 5 programming language system itself.
86  
87 =cut
« Smooth/Lookup/DateTime/year.pm ↑ Summary Smooth.pm »