From: Luke Saunders Date: Thu, 7 Aug 2008 01:31:51 +0000 (+0000) Subject: further simplified compose_namespace X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a6e48350d8b1fa0cba024dc696391ee4f1f448b0;p=dbsrgits%2FDBIx-Class-Historic.git further simplified compose_namespace --- diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 5576378..ea6f599 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -615,26 +615,23 @@ will produce the output =cut +# this might be oversimplified sub compose_namespace { my ($self, $target, $base) = @_; - $self = $self->clone; - foreach my $moniker ($self->sources) { - my $source = $self->source($moniker); - my $source_class = ref $source; - my $source_copy = $source_class->new({ - %$source, - _relationships => Storable::dclone( $source->_relationships ), - }); - - my $target_class = "${target}::${moniker}"; - $self->inject_base( - $target_class => $source_copy->result_class, ($base ? $base : ()) - ); - $source_copy->result_class($target_class); - $self->register_source($moniker, $source_copy); + my $schema = $self->clone; + foreach my $moniker ($schema->sources) { + my $source = $schema->source($moniker); + my $target_class = "${target}::${moniker}"; + $self->inject_base( + $target_class => $source->result_class, ($base ? $base : ()) + ); + $source->result_class($target_class); + $target_class->result_source_instance($source) + if $target_class->can('result_source_instance'); + $schema->register_source($moniker, $source); } - return $self; + return $schema; } sub setup_connection_class {