blib/lib/DBIx/Class/IntrospectableM2M.pm

filter: Statementstmt 100% 19 / 19 Branchbran 50.0% 2 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 4 / 4 Podpod 100% 1 / 1 totaltotal 92.8% 26 / 28 SCAR 11.0
CC
3
Cov
91%
many_to_many
3.1
BEGIN
1.0
BEGIN
1.0
CRAP 3.0
↑ Summary
1 package DBIx::Class::IntrospectableM2M;
2  
3 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use base 'DBIx::Class';
Subroutine BEGIN: called CC=1 SCAR=0.0
6  
7 1 our $VERSION = '0.001001';
8  
9 #namespace pollution. sadface.
10 1 __PACKAGE__->mk_classdata( _m2m_metadata => {} );
11  
12 sub many_to_many {
13 2 ▶ my $class = shift;
Subroutine many_to_many: called CC=3 SCAR=11.2
Pod documented
14 2 my ($meth_name, $link, $far_side) = @_;
15 2 my $store = $class->_m2m_metadata;
16 warn("You are overwritting another relationship's metadata")
17 2 ▶ if exists $store->{$meth_name};
Branch: 1 branch
BranchTrueFalseTotal
if exists $store->{$meth_name} 0 2 2
18  
19 2 ▶ my $attrs = {
Branch: 1 branch
BranchTrueFalseTotal
@_ > 3 ? : 0 2 2
20 accessor => $meth_name,
21 relation => $link, #"link" table or imediate relation
22 foreign_relation => $far_side, #'far' table or foreign relation
23 (@_ > 3 ? (attrs => $_[3]) : ()), #only store if exist
24 rs_method => "${meth_name}_rs", #for completeness..
25 add_method => "add_to_${meth_name}",
26 set_method => "set_${meth_name}",
27 remove_method => "remove_from_${meth_name}",
28 };
29  
30 #inheritable data workaround
31 2 $class->_m2m_metadata({ $meth_name => $attrs, %$store});
32 2 $class->next::method(@_);
33 }
34  
35 1 1;
36  
37 __END__;
↑ Summary