Commit | Line | Data |
8973b6f1 |
1 | package DBIx::Class::Relationship::ManyToMany; |
2 | |
3 | use strict; |
4 | use warnings; |
5 | |
6 | sub many_to_many { |
78af1010 |
7 | my ($class, $meth, $rel, $f_rel, $rel_attrs) = @_; |
8973b6f1 |
8 | { |
9 | no strict 'refs'; |
10 | no warnings 'redefine'; |
78af1010 |
11 | *{"${class}::${meth}"} = sub { |
0f6ac8bb |
12 | my $self = shift; |
13 | my $attrs = @_ > 1 && ref $_[$#_] eq 'HASH' ? pop(@_) : {}; |
aeb1bf75 |
14 | $self->search_related($rel)->search_related($f_rel, @_ > 0 ? @_ : undef, { %{$rel_attrs||{}}, %$attrs }); |
78af1010 |
15 | }; |
8973b6f1 |
16 | } |
17 | } |
18 | |
19 | 1; |