line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package # hide from PAUSE |
2
|
|
|
|
|
|
|
DBIx::Class::Relationship::ProxyMethods; |
3
|
|
|
|
|
|
|
|
4
|
379
|
|
|
379
|
|
174092
|
use strict; |
|
379
|
|
|
|
|
1298
|
|
|
379
|
|
|
|
|
11219
|
|
5
|
379
|
|
|
379
|
|
2186
|
use warnings; |
|
379
|
|
|
|
|
1135
|
|
|
379
|
|
|
|
|
10085
|
|
6
|
379
|
|
|
379
|
|
2106
|
use base 'DBIx::Class'; |
|
379
|
|
|
|
|
1129
|
|
|
379
|
|
|
|
|
43236
|
|
7
|
379
|
|
|
379
|
|
2972
|
use DBIx::Class::_Util 'quote_sub'; |
|
379
|
|
|
|
|
1221
|
|
|
379
|
|
|
|
|
17517
|
|
8
|
379
|
|
|
379
|
|
2618
|
use namespace::clean; |
|
379
|
|
|
|
|
1177
|
|
|
379
|
|
|
|
|
2949
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
our %_pod_inherit_config = |
11
|
|
|
|
|
|
|
( |
12
|
|
|
|
|
|
|
class_map => { 'DBIx::Class::Relationship::ProxyMethods' => 'DBIx::Class::Relationship' } |
13
|
|
|
|
|
|
|
); |
14
|
|
|
|
|
|
|
|
15
|
|
|
|
|
|
|
sub register_relationship { |
16
|
29086
|
|
|
29086
|
0
|
476834
|
my ($class, $rel, $info) = @_; |
17
|
29086
|
100
|
|
|
|
122650
|
if (my $proxy_args = $info->{attrs}{proxy}) { |
18
|
1978
|
|
|
|
|
17791
|
$class->proxy_to_related($rel, $proxy_args); |
19
|
|
|
|
|
|
|
} |
20
|
29084
|
|
|
|
|
466576
|
$class->next::method($rel, $info); |
21
|
|
|
|
|
|
|
} |
22
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
sub proxy_to_related { |
24
|
1978
|
|
|
1978
|
0
|
5222
|
my ($class, $rel, $proxy_args) = @_; |
25
|
1978
|
|
|
|
|
13204
|
my %proxy_map = $class->_build_proxy_map_from($proxy_args); |
26
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
quote_sub "${class}::$_", sprintf( <<'EOC', $rel, $proxy_map{$_} ) |
28
|
|
|
|
|
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
my $relobj = $self->%1$s; |
30
|
|
|
|
|
|
|
if (@_ && !defined $relobj) { |
31
|
|
|
|
|
|
|
$relobj = $self->create_related( %1$s => { %2$s => $_[0] } ); |
32
|
|
|
|
|
|
|
@_ = (); |
33
|
|
|
|
|
|
|
} |
34
|
|
|
|
|
|
|
$relobj ? $relobj->%2$s(@_) : undef; |
35
|
|
|
|
|
|
|
EOC |
36
|
1976
|
|
|
|
|
21751
|
for keys %proxy_map |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub _build_proxy_map_from { |
40
|
1978
|
|
|
1978
|
|
5182
|
my ( $class, $proxy_arg ) = @_; |
41
|
1978
|
|
|
|
|
4845
|
my $ref = ref $proxy_arg; |
42
|
|
|
|
|
|
|
|
43
|
1978
|
100
|
|
|
|
8876
|
if ($ref eq 'HASH') { |
|
|
100
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
44
|
988
|
|
|
|
|
6068
|
return %$proxy_arg; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
elsif ($ref eq 'ARRAY') { |
47
|
|
|
|
|
|
|
return map { |
48
|
661
|
100
|
|
|
|
2150
|
(ref $_ eq 'HASH') |
|
986
|
|
|
|
|
6683
|
|
49
|
|
|
|
|
|
|
? (%$_) |
50
|
|
|
|
|
|
|
: ($_ => $_) |
51
|
|
|
|
|
|
|
} @$proxy_arg; |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
elsif ($ref) { |
54
|
2
|
|
|
|
|
17
|
$class->throw_exception("Unable to process the 'proxy' argument $proxy_arg"); |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
else { |
57
|
327
|
|
|
|
|
1629
|
return ( $proxy_arg => $proxy_arg ); |
58
|
|
|
|
|
|
|
} |
59
|
|
|
|
|
|
|
} |
60
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |