X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FRelationship%2FProxyMethods.pm;h=7b76499c6534221414e833292cc2bcc4e167d1d9;hb=336feb8ef85d16d22ae0b131b0c7a85abc9e9435;hp=51e65e39fb91f82a058788d5daaadda731638199;hpb=147dd158cf91465b8a48adce738d56b85f7d1b9b;p=dbsrgits%2FDBIx-Class.git diff --git a/lib/DBIx/Class/Relationship/ProxyMethods.pm b/lib/DBIx/Class/Relationship/ProxyMethods.pm index 51e65e3..7b76499 100644 --- a/lib/DBIx/Class/Relationship/ProxyMethods.pm +++ b/lib/DBIx/Class/Relationship/ProxyMethods.pm @@ -1,18 +1,23 @@ -package DBIx::Class::Relationship::ProxyMethods; +package # hide from PAUSE + DBIx::Class::Relationship::ProxyMethods; use strict; use warnings; +use Sub::Name (); +use base qw/DBIx::Class/; -use base qw/Class::Data::Inheritable/; +our %_pod_inherit_config = + ( + class_map => { 'DBIx::Class::Relationship::ProxyMethods' => 'DBIx::Class::Relationship' } + ); -sub add_relationship { - my ($class, $rel, @rest) = @_; - my $ret = $class->next::method($rel => @rest); - if (my $proxy_list = $class->_relationships->{$rel}->{attrs}{proxy}) { +sub register_relationship { + my ($class, $rel, $info) = @_; + if (my $proxy_list = $info->{attrs}{proxy}) { $class->proxy_to_related($rel, (ref $proxy_list ? @$proxy_list : $proxy_list)); } - return $ret; + $class->next::method($rel, $info); } sub proxy_to_related { @@ -20,7 +25,8 @@ sub proxy_to_related { no strict 'refs'; no warnings 'redefine'; foreach my $proxy (@proxy) { - *{"${class}::${proxy}"} = + my $name = join '::', $class, $proxy; + *$name = Sub::Name::subname $name, sub { my $self = shift; my $val = $self->$rel;