From: Dagfinn Ilmari Mannsåker Date: Tue, 27 May 2008 01:20:12 +0000 (+0000) Subject: Move the _dump_to_dir calls into _reload_classes X-Git-Tag: 0.04999_06~4 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=181cc907dd090d331ab5e1d9b31fc9904124b64f;p=dbsrgits%2FDBIx-Class-Schema-Loader.git Move the _dump_to_dir calls into _reload_classes --- diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 77dcd29..a78ba9e 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -385,14 +385,10 @@ sub _load_tables { $self->_make_src_class($_) for @tables; $self->_setup_src_meta($_) for @tables; - my %moniker_class = map { $self->monikers->{$_} => $self->classes->{$_} } @tables; - if(!$self->skip_relationships) { - # Dump and load what we have so far, so the relationship loader - # can get at it, but be quiet + # The relationship loader needs a working schema $self->{quiet} = 1; - $self->_dump_to_dir(values %moniker_class); - $self->_reload_classes(\%moniker_class); + $self->_reload_classes(@tables); $self->_load_relationships($_) for @tables; $self->{quiet} = 0; } @@ -400,10 +396,7 @@ sub _load_tables { $self->_load_external($_) for map { $self->classes->{$_} } @tables; - $self->_dump_to_dir(values %moniker_class); - - # Make sure stuff gets reloaded - $self->_reload_classes(\%moniker_class); + $self->_reload_classes(@tables); # Drop temporary cache delete $self->{_cache}; @@ -412,9 +405,14 @@ sub _load_tables { } sub _reload_classes { - my ($self, $moniker_class) = @_; + my ($self, @tables) = @_; + + $self->_dump_to_dir(map { $self->classes->{$_} } @tables); - while (my ($moniker, $class) = each %$moniker_class) { + for my $table (@tables) { + my $moniker = $self->monikers->{$table}; + my $class = $self->classes->{$table}; + if ( Class::Unload->unload( $class ) ) { my $resultset_class = ref $self->schema->resultset($moniker); Class::Unload->unload( $resultset_class )