Factor out remote relname for back-compat overridability
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader.pm
index d1e3f46..edc3df3 100644 (file)
@@ -4,14 +4,13 @@ use strict;
 use warnings;
 use base qw/DBIx::Class::Schema Class::Data::Accessor/;
 use Carp::Clan qw/^DBIx::Class/;
-use UNIVERSAL::require;
 use Class::C3;
 use Scalar::Util qw/ weaken /;
 
 # 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.04999_04';
+our $VERSION = '0.04999_07';
 
 __PACKAGE__->mk_classaccessor('_loader_args' => {});
 __PACKAGE__->mk_classaccessors(qw/dump_to_dir _loader_invoked _loader loader_class/);
@@ -71,6 +70,12 @@ the road.
 
 =head2 loader_class
 
+=over 4
+
+=item Argument: $loader_class
+
+=back
+
 Set the loader class to be instantiated when L</connection> is called.
 If the classname starts with "::", "DBIx::Class::Schema::Loader" is
 prepended. Defaults to L<DBIx::Class::Schema/storage_type> (which must
@@ -81,6 +86,12 @@ with L</dump_to_dir>.
 
 =head2 loader_options
 
+=over 4
+
+=item Argument: \%loader_options
+
+=back
+
 Example in Synopsis above demonstrates a few common arguments.  For
 detailed information on all of the arguments, most of which are
 only useful in fairly complex scenarios, see the
@@ -119,9 +130,8 @@ sub _invoke_loader {
     my $impl = $self->loader_class
       || "DBIx::Class::Schema::Loader" . $self->storage_type;
     $impl = "DBIx::Class::Schema::Loader${impl}" if $impl =~ /^::/;
-    $impl->require or
-      croak qq/Could not load storage_type loader "$impl": / .
-            qq/"$UNIVERSAL::require::ERROR"/;
+    eval { $self->ensure_class_loaded($impl) };
+    croak qq/Could not load storage_type loader "$impl": "$@"/ if $@;
 
     $self->_loader($impl->new(%$args));
     $self->_loader->load;
@@ -132,7 +142,15 @@ sub _invoke_loader {
 
 =head2 connection
 
-See L<DBIx::Class::Schema> for basic usage.
+=over 4
+
+=item Arguments: @args
+
+=item Return Value: $new_schema
+
+=back
+
+See L<DBIx::Class::Schema/connection> for basic usage.
 
 If the final argument is a hashref, and it contains the keys C<loader_options>
 or C<loader_class>, those keys will be deleted, and their values value will be
@@ -148,7 +166,7 @@ sub connection {
     my $self = shift;
 
     if($_[-1] && ref $_[-1] eq 'HASH') {
-        for my $option (qw/ loader_class loader_options /) {
+        for my $option (qw/ loader_class loader_options result_base_class schema_base_class/) {
             if(my $value = delete $_[-1]->{$option}) {
                 $self->$option($value);
             }
@@ -168,7 +186,7 @@ sub connection {
 
 =head2 clone
 
-See L<DBIx::Class::Schema>.
+See L<DBIx::Class::Schema/clone>.
 
 =cut
 
@@ -187,7 +205,11 @@ sub clone {
 
 =head2 dump_to_dir
 
-Argument: directory name.
+=over 4
+
+=item Argument: $directory
+
+=back
 
 Calling this as a class method on either L<DBIx::Class::Schema::Loader>
 or any derived schema class will cause all affected schemas to dump
@@ -253,6 +275,14 @@ sub import {
 
 =head2 make_schema_at
 
+=over 4
+
+=item Arguments: $schema_name, \%loader_options, \@connect_info
+
+=item Return Value: $schema_name
+
+=back
+
 This simple function allows one to create a Loader-based schema
 in-memory on the fly without any on-disk class files of any
 kind.  When used with the C<dump_directory> option, you can
@@ -302,6 +332,12 @@ sub make_schema_at {
 
 =head2 rescan
 
+=over 4
+
+=item Return Value: @new_monikers
+
+=back
+
 Re-scans the database for newly added tables since the initial
 load, and adds them to the schema at runtime, including relationships,
 etc.  Does not process drops or changes.