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