blob: 7e8146c20d7387cb6a93893edb0a241b493dffab (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
package DBIx::Class::IntrospectableM2M;
use strict;
use warnings;
use base 'DBIx::Class';
#namespace pollution. sadface.
__PACKAGE__->mk_classdata( _m2m_metadata => {} );
sub many_to_many {
my $class = shift;
my ($meth_name, $link, $far_side) = @_;
$class->_m2m_metadata->{$meth_name} =
{
accessor => $meth_name,
relation => $link, #"link" table or imediate relation
foreign_relation => $far_side, #'far' table or foreign relation
(@_ > 3 ? (attrs => $_[3]) : ()), #only store if exist
rs_method => "${meth_name}_rs", #for completeness..
add_method => "add_to_${meth_name}",
set_method => "set_${meth_name}",
remove_method => "remove_from_${meth_name}",
};
$class->next::method(@_);
}
1;
|