cleanup ResultSource a bit, plus a couple trivial cleanups
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Relationship / ManyToMany.pm
CommitLineData
8973b6f1 1package DBIx::Class::Relationship::ManyToMany;
2
3use strict;
4use warnings;
5
6sub many_to_many {
78af1010 7 my ($class, $meth, $rel, $f_rel, $rel_attrs) = @_;
8 $rel_attrs ||= {};
8973b6f1 9
10 {
11 no strict 'refs';
12 no warnings 'redefine';
78af1010 13 *{"${class}::${meth}"} = sub {
0f6ac8bb 14 my $self = shift;
15 my $attrs = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {};
16 $self->search_related($rel)->search_related($f_rel, @_ > 0 ? @_ : undef, { %$rel_attrs, %$attrs });
78af1010 17 };
8973b6f1 18 }
19}
20
211;