From: Brandon Black Date: Tue, 28 Feb 2006 15:23:46 +0000 (+0000) Subject: move external file loading, release 0.02005 X-Git-Tag: 0.03000~10 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d161cb49e1ccbad6f8d16de33e930d516dff1e71;hp=1b311bbba76fa1728cf03cb31e72a4bd8a4572a7;p=dbsrgits%2FDBIx-Class-Schema-Loader.git move external file loading, release 0.02005 --- diff --git a/Changes b/Changes index ca6d164..9cf83a4 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,10 @@ Revision history for Perl extension DBIx::Class::Schema::Loader +0.02005 Mon Feb 27 23:53:17 UTC 2006 + - Move the external file loading to after everything else + loader does, in case people want to define, override, or + build on top of the rels. + 0.02004 Mon Feb 27 23:53:17 UTC 2006 - Minor fix to debugging message for loading external files diff --git a/META.yml b/META.yml index a20dce0..b530fa3 100644 --- a/META.yml +++ b/META.yml @@ -1,6 +1,6 @@ --- name: DBIx-Class-Schema-Loader -version: 0.02004 +version: 0.02005 author: - 'Brandon Black, C' abstract: Dynamic definition of a DBIx::Class::Schema @@ -20,7 +20,7 @@ build_requires: provides: DBIx::Class::Schema::Loader: file: lib/DBIx/Class/Schema/Loader.pm - version: 0.02004 + version: 0.02005 DBIx::Class::Schema::Loader::DB2: file: lib/DBIx/Class/Schema/Loader/DB2.pm DBIx::Class::Schema::Loader::Generic: diff --git a/lib/DBIx/Class/Schema/Loader.pm b/lib/DBIx/Class/Schema/Loader.pm index 5fb8d45..bfb867a 100644 --- a/lib/DBIx/Class/Schema/Loader.pm +++ b/lib/DBIx/Class/Schema/Loader.pm @@ -10,7 +10,7 @@ use UNIVERSAL::require; # Always remember to do all digits for the version even if they're 0 # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports # brain damage and presumably various other packaging systems too -our $VERSION = '0.02004'; +our $VERSION = '0.02005'; __PACKAGE__->mk_classaccessor('loader'); diff --git a/lib/DBIx/Class/Schema/Loader/Generic.pm b/lib/DBIx/Class/Schema/Loader/Generic.pm index 52804fb..5ecb46b 100644 --- a/lib/DBIx/Class/Schema/Loader/Generic.pm +++ b/lib/DBIx/Class/Schema/Loader/Generic.pm @@ -221,6 +221,7 @@ sub load { $self->_load_classes; $self->_load_relationships if $self->relationships; + $self->_load_external; warn qq/\### END DBIx::Class::Schema::Loader dump ###\n/ if $self->debug; @@ -229,6 +230,22 @@ sub load { $self; } +sub _load_external { + my $self = shift; + + foreach my $table_class (values %{$self->classes}) { + $table_class->require; + if($@ && $@ !~ /^Can't locate /) { + croak "Failed to load external class definition" + . "for '$table_class': $@"; + } + elsif(!$@) { + warn qq/# Loaded external class definition for '$table_class'\n/ + if $self->debug; + } + } +} + # Overload in your driver class sub _db_classes { croak "ABSTRACT METHOD" } @@ -397,16 +414,6 @@ sub _load_classes { warn qq/$table_class->set_primary_key('$primaries')\n/ if $self->debug && @$pks; - $table_class->require; - if($@ && $@ !~ /^Can't locate /) { - croak "Failed to load external class definition" - . "for '$table_class': $@"; - } - elsif(!$@) { - warn qq/# Loaded external class definition for '$table_class'\n/ - if $self->debug; - } - $schema->register_class($table_moniker, $table_class); $self->classes->{$lc_tblname} = $table_class; $self->monikers->{$lc_tblname} = $table_moniker;