1 package # hide from PAUSE
2 DBIx::Class::Relationship::ProxyMethods;
7 use base qw/DBIx::Class/;
9 sub register_relationship {
10 my ($class, $rel, $info) = @_;
11 if (my $proxy_list = $info->{attrs}{proxy}) {
12 $class->proxy_to_related($rel,
13 (ref $proxy_list ? @$proxy_list : $proxy_list));
15 $class->next::method($rel, $info);
18 sub proxy_to_related {
19 my ($class, $rel, @proxy) = @_;
21 no warnings 'redefine';
22 foreach my $proxy (@proxy) {
23 *{"${class}::${proxy}"} =
26 my $val = $self->$rel;
27 if (@_ && !defined $val) {
28 $val = $self->create_related($rel, { $proxy => $_[0] });
31 return ($val ? $val->$proxy(@_) : undef);