From: Brandon L. Black Date: Thu, 27 Jul 2006 06:08:10 +0000 (+0000) Subject: proxy result_class, and fix load_namespace to use it correctly X-Git-Tag: v0.08010~43^2~22^2~7 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=fdcd81457bcc74ed95a6c3e1c75101a3f90b214e;p=dbsrgits%2FDBIx-Class.git proxy result_class, and fix load_namespace to use it correctly --- diff --git a/lib/DBIx/Class/ResultSourceProxy.pm b/lib/DBIx/Class/ResultSourceProxy.pm index 591927f..4c52fa0 100644 --- a/lib/DBIx/Class/ResultSourceProxy.pm +++ b/lib/DBIx/Class/ResultSourceProxy.pm @@ -8,6 +8,7 @@ use base qw/DBIx::Class/; sub iterator_class { shift->result_source_instance->resultset_class(@_) } sub resultset_class { shift->result_source_instance->resultset_class(@_) } +sub result_class { shift->result_source_instance->result_class(@_) } sub source_name { shift->result_source_instance->source_name(@_) } sub resultset_attributes { diff --git a/lib/DBIx/Class/Schema.pm b/lib/DBIx/Class/Schema.pm index 63d0ca4..0ec1897 100644 --- a/lib/DBIx/Class/Schema.pm +++ b/lib/DBIx/Class/Schema.pm @@ -393,6 +393,19 @@ sub load_namespaces { . "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 ]); } } @@ -402,29 +415,14 @@ sub load_namespaces { . '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; }