sub many_to_many {
my $class = shift;
my ($meth_name, $link, $far_side) = @_;
+ my $store = $class->_m2m_metadata;
+ die("You are overwritting another relationship's metadata")
+ if exists $store->{$meth_name};
- $class->_m2m_metadata->{$meth_name} =
+ my $attrs =
{
- accessor => $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
remove_method => "remove_from_${meth_name}",
};
+ #inheritable data workaround/
+ $class->_m2m_metadata({ $meth_name => $attrs, %$store});
+
$class->next::method(@_);
}
},
);
-# my %debug_attr_opts =
-# (
-# lazy => 1,
-# required => 1,
-# isa => $collection,
-# reader => $reader,
-# predicate => "has_" . $self->_class_to_attribute_name($name) ,
-# domain_model => $dm_name,
-# orig_attr_name => $source,
-# default => qq^sub {
-# my \$self = \$_[0];
-# return $collection->new(
-# _source_resultset => \$self->$dm_name->resultset("$source"),
-# _parent => \$self,
-# );
-# }, ^,
-# );
-
-
-
my $make_immutable = $meta->is_immutable;
$meta->make_mutable if $make_immutable;
my $attr = $meta->add_attribute($name, %attr_opts);