Helper/Row/RelationshipDWIM.pm

filter: Statementstmt 96.4% 27 / 28 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 87.5% 7 / 8 Podpod 0.0% 0 / 5 totaltotal 82.9% 34 / 41 CC 1 SCAR 1.2
CC
1
Cov
96%
default_result_namespace
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.1
« Helper/Row/SubClass.pm ↑ Summary Helper/Schema/DateTime.pm »
1 package DBIx::Class::Helper::Row::RelationshipDWIM;
2 55 $DBIx::Class::Helper::Row::RelationshipDWIM::VERSION = '2.033001';
3 # ABSTRACT: Type less for your relationships!
4  
5 55 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 55 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 55 ▶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 55 ▶ my ( $self, @args ) = @_;
Subroutine belongs_to: called CC=1 SCAR=0.0
Pod undocumented
16  
17 55 $args[1] =~ s/^::/$self->default_result_namespace . '::'/e;
18  
19 55 $self->next::method(@args);
20 }
21  
22 sub has_many {
23 55 ▶ my ( $self, @args ) = @_;
Subroutine has_many: called CC=1 SCAR=0.0
Pod undocumented
24  
25 55 $args[1] =~ s/^::/$self->default_result_namespace . '::'/e;
26  
27 55 $self->next::method(@args);
28 }
29  
30 sub might_have {
31 55 ▶ my ( $self, @args ) = @_;
Subroutine might_have: called CC=1 SCAR=0.0
Pod undocumented
32  
33 55 $args[1] =~ s/^::/$self->default_result_namespace . '::'/e;
34  
35 55 $self->next::method(@args);
36 }
37  
38 sub has_one {
39 55 ▶ my ( $self, @args ) = @_;
Subroutine has_one: called CC=1 SCAR=0.0
Pod undocumented
40  
41 55 $args[1] =~ s/^::/$self->default_result_namespace . '::'/e;
42  
43 55 $self->next::method(@args);
44 }
45  
46 55 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 # succinct 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/Row/SubClass.pm ↑ Summary Helper/Schema/DateTime.pm »