use Carp::Clan qw/^DBIx::Class/;
use Scalar::Util qw/weaken/;
+require Module::Find;
use base qw/DBIx::Class/;
}
}
} else {
- eval "require Module::Find;";
- $class->throw_exception(
- "No arguments to load_classes and couldn't load Module::Find ($@)"
- ) if $@;
my @comp = map { substr $_, length "${class}::" }
Module::Find::findallmod($class);
$comps_for{$class} = \@comp;
the schema classname by default. To specify a fully-qualified name, prefix
it with a literal C<+>.
-This method requires L<Module::Find> to be installed on the system.
-
Example:
# load My::Schema::ResultSource::CD, My::Schema::ResultSource::Artist,
$_ = $class . '::' . $_ if !s/^\+//;
}
- eval "require Module::Find";
- $class->throw_exception("Couldn't load Module::Find ($@)") if $@;
-
my %sources = map { (substr($_, length "${resultsource_namespace}::"), $_) }
Module::Find::findallmod($resultsource_namespace);
. "that you had already set '$source' to use '$rs_set' instead";
}
+ my $r_class = delete $results{$source};
+ if($r_class) {
+ my $r_set = $source_class->result_class;
+ if(!$r_set || $r_set eq $sources{$source}) {
+ $class->ensure_class_loaded($r_class);
+ $source_class->result_class($r_class);
+ }
+ else {
+ warn "We found Result class '$r_class' for '$source', but it seems "
+ . "that you had already set '$source' to use '$r_set' instead";
+ }
+ }
+
push(@to_register, [ $source_class->source_name, $source_class ]);
}
}
. 'corresponding ResultSource';
}
- Class::C3->reinitialize;
- $class->register_class(@$_) for (@to_register);
-
- foreach my $source (keys %sources) {
- my $r_class = delete $results{$source};
- if($r_class) {
- my $r_set = $class->source($source)->result_class;
- if(!$r_set || $r_set eq $sources{$source}) {
- $class->ensure_class_loaded($r_class);
- $class->source($source)->result_class($r_class);
- }
- else {
- warn "We found Result class '$r_class' for '$source', but it seems "
- . "that you had already set '$source' to use '$r_set' instead";
- }
- }
- }
-
foreach (sort keys %results) {
warn "load_namespaces found Result class $_ with no "
. 'corresponding ResultSource';
}
+ Class::C3->reinitialize;
+ $class->register_class(@$_) for (@to_register);
+
return;
}