Helper/Row/RelationshipDWIM.pm

filter: Statementstmt 67.8% 19 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 62.5% 5 / 8 Podpod 0.0% 0 / 5 totaltotal 58.5% 24 / 41 CC 1 SCAR 3.2
CC
1
Cov
68%
default_result_namespace
2.0
might_have
2.0
has_one
2.0
CRAP 1.4
« Helper/Schema/GenerateSource.pm ↑ Summary Helper/ResultSet/SearchOr.pm »
1 package DBIx::Class::Helper::Row::RelationshipDWIM;
2 54 $DBIx::Class::Helper::Row::RelationshipDWIM::VERSION = '2.032002';
3 # ABSTRACT: Type less for your relationships!
4  
5 54 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 54 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 54 ▶use parent 'DBIx::Class::Row';
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 sub default_result_namespace {
11 0 ▶ die 'you forgot to set your default_result_namespace'
Subroutine default_result_namespace: not called CC=1 SCAR=6.9
Pod undocumented
12 }
13  
14 sub belongs_to {
15 54 ▶ my ( $self, @args ) = @_;
Subroutine belongs_to: called CC=1 SCAR=0.0
Pod undocumented
16  
17 54 $args[1] =~ s/^::/$self->default_result_namespace . '::'/e;
18  
19 54 $self->next::method(@args);
20 }
21  
22 sub has_many {
23 54 ▶ my ( $self, @args ) = @_;
Subroutine has_many: called CC=1 SCAR=0.0
Pod undocumented
24  
25 54 $args[1] =~ s/^::/$self->default_result_namespace . '::'/e;
26  
27 54 $self->next::method(@args);
28 }
29  
30 sub might_have {
31 0 ▶ my ( $self, @args ) = @_;
Subroutine might_have: not called CC=1 SCAR=6.9
Pod undocumented
32  
33 0 $args[1] =~ s/^::/$self->default_result_namespace . '::'/e;
34  
35 0 $self->next::method(@args);
36 }
37  
38 sub has_one {
39 0 ▶ my ( $self, @args ) = @_;
Subroutine has_one: not called CC=1 SCAR=6.9
Pod undocumented
40  
41 0 $args[1] =~ s/^::/$self->default_result_namespace . '::'/e;
42  
43 0 $self->next::method(@args);
44 }
45  
46 54 1;
47  
48 __END__
49  
50 =pod
51  
52 =head1 NAME
53  
54 DBIx::Class::Helper::Row::RelationshipDWIM - Type less for your relationships!
55  
56 =head1 SYNOPSIS
57  
58 Base clase:
59  
60 package MyApp::Schema::Result;
61  
62 use parent 'DBIx::Class::Core';
63  
64 __PACKAGE__->load_components('Helper::Row::RelationshipDWIM');
65  
66 sub default_result_namespace { 'MyApp::Schema::Result' }
67  
68 1;
69  
70 Result class:
71  
72 package MyApp::Schema::Result::Foo;
73  
74 use parent 'MyApp::Schema::Result';
75  
76 # Define various class bits here
77  
78 # succint relationship definition yeah!
79  
80 __PACKAGE__->has_many(friends => '::Person', 'foo_id');
81  
82 # or with DBIx::Class::Candy:
83 has_many friends => '::Person', 'foo_id';
84  
85 1;
86  
87 =head1 DESCRIPTION
88  
89 This module prepends your C<default_result_namespace> to related objects if they
90 begin with C<::>. Simple but handy.
91  
92 =head1 AUTHOR
93  
94 Arthur Axel "fREW" Schmidt <frioux+cpan@gmail.com>
95  
96 =head1 COPYRIGHT AND LICENSE
97  
98 This software is copyright (c) 2016 by Arthur Axel "fREW" Schmidt.
99  
100 This is free software; you can redistribute it and/or modify it under
101 the same terms as the Perl 5 programming language system itself.
102  
103 =cut
« Helper/Schema/GenerateSource.pm ↑ Summary Helper/ResultSet/SearchOr.pm »