From: David Kamholz Date: Tue, 31 Jan 2006 23:18:47 +0000 (+0000) Subject: let many_to_many rels have attrs X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=78af1010e7fb71c50d441fb0f86dcc9b77ee3ac2;p=dbsrgits%2FDBIx-Class-Historic.git let many_to_many rels have attrs --- diff --git a/lib/DBIx/Class/Relationship/ManyToMany.pm b/lib/DBIx/Class/Relationship/ManyToMany.pm index 09fd212..f01cc10 100644 --- a/lib/DBIx/Class/Relationship/ManyToMany.pm +++ b/lib/DBIx/Class/Relationship/ManyToMany.pm @@ -4,15 +4,16 @@ use strict; use warnings; sub many_to_many { - my ($class, $meth, $rel_class, $f_class) = @_; - - eval "require $f_class"; + my ($class, $meth, $rel, $f_rel, $rel_attrs) = @_; + $rel_attrs ||= {}; { no strict 'refs'; no warnings 'redefine'; - *{"${class}::${meth}"} = - sub { shift->search_related($rel_class)->search_related($f_class, @_); }; + *{"${class}::${meth}"} = sub { + my ($self,$cond,$attrs) = @_; + $self->search_related($rel)->search_related($f_rel, $cond, { %$rel_attrs, %{$attrs||{}} }); + }; } }