method schema (@args) {
my $ret = $self->next::method(@args);
if (@args) {
- $self->_attach_additional_sources;
+ if ($self->parent_source) {
+ my $schema = $self->schema;
+ my $parent_name = $self->parent_source->name;
+ my ($parent) =
+ grep { $_->name eq $parent_name }
+ map $schema->source($_), $schema->sources;
+ confess "Couldn't find attached source for parent $parent_name - did you use load_classes? This module is only compatible with load_namespaces"
+ unless $parent;
+ $self->parent_source($parent); # so our parent is the one in this schema
+ }
}
return $ret;
}
-method _attach_additional_sources () {
+method attach_additional_sources () {
my $raw_name = $self->raw_source_name;
my $schema = $self->schema;
use strict;
use warnings;
use parent qw(DBIx::Class::Schema);
+use aliased 'DBIx::Class::ResultSource::MultipleTableInheritance' => 'MTIView';
-__PACKAGE__->load_namespaces;
+for my $p (__PACKAGE__) {
+ $p->load_namespaces;
+ $_->attach_additional_sources
+ for grep $_->isa(MTIView), map $p->source($_), $p->sources;
+}
1;