line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package DBIx::Class::Helper::Row::RelationshipDWIM; |
2
|
|
|
|
|
|
|
$DBIx::Class::Helper::Row::RelationshipDWIM::VERSION = '2.036000'; |
3
|
|
|
|
|
|
|
# ABSTRACT: Type less for your relationships! |
4
|
|
|
|
|
|
|
|
5
|
57
|
|
|
57
|
|
6448201
|
use strict; |
|
57
|
|
|
|
|
342
|
|
|
57
|
|
|
|
|
1605
|
|
6
|
57
|
|
|
57
|
|
304
|
use warnings; |
|
57
|
|
|
|
|
132
|
|
|
57
|
|
|
|
|
1412
|
|
7
|
|
|
|
|
|
|
|
8
|
57
|
|
|
57
|
|
285
|
use parent 'DBIx::Class::Row'; |
|
57
|
|
|
|
|
116
|
|
|
57
|
|
|
|
|
275
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub default_result_namespace { |
11
|
0
|
|
|
0
|
0
|
0
|
die 'you forgot to set your default_result_namespace' |
12
|
|
|
|
|
|
|
} |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub belongs_to { |
15
|
57
|
|
|
57
|
0
|
334903
|
my ( $self, @args ) = @_; |
16
|
|
|
|
|
|
|
|
17
|
57
|
|
|
|
|
352
|
$args[1] =~ s/^::/$self->default_result_namespace . '::'/e; |
|
57
|
|
|
|
|
296
|
|
18
|
|
|
|
|
|
|
|
19
|
57
|
|
|
|
|
490
|
$self->next::method(@args); |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub has_many { |
23
|
57
|
|
|
57
|
0
|
174619
|
my ( $self, @args ) = @_; |
24
|
|
|
|
|
|
|
|
25
|
57
|
|
|
|
|
446
|
$args[1] =~ s/^::/$self->default_result_namespace . '::'/e; |
|
57
|
|
|
|
|
274
|
|
26
|
|
|
|
|
|
|
|
27
|
57
|
|
|
|
|
450
|
$self->next::method(@args); |
28
|
|
|
|
|
|
|
} |
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
sub might_have { |
31
|
57
|
|
|
57
|
0
|
30278
|
my ( $self, @args ) = @_; |
32
|
|
|
|
|
|
|
|
33
|
57
|
|
|
|
|
367
|
$args[1] =~ s/^::/$self->default_result_namespace . '::'/e; |
|
57
|
|
|
|
|
400
|
|
34
|
|
|
|
|
|
|
|
35
|
57
|
|
|
|
|
499
|
$self->next::method(@args); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub has_one { |
39
|
57
|
|
|
57
|
0
|
50081
|
my ( $self, @args ) = @_; |
40
|
|
|
|
|
|
|
|
41
|
57
|
|
|
|
|
434
|
$args[1] =~ s/^::/$self->default_result_namespace . '::'/e; |
|
57
|
|
|
|
|
262
|
|
42
|
|
|
|
|
|
|
|
43
|
57
|
|
|
|
|
447
|
$self->next::method(@args); |
44
|
|
|
|
|
|
|
} |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
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) 2020 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 |