Merge 'DBIx-Class-current' into 'many_to_many'
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / Relationship / HasOne.pm
index 66662c9..aa94a08 100644 (file)
@@ -1,4 +1,5 @@
-package DBIx::Class::Relationship::HasOne;
+package # hide from PAUSE
+    DBIx::Class::Relationship::HasOne;
 
 use strict;
 use warnings;
@@ -13,18 +14,13 @@ sub has_one {
 
 sub _has_one {
   my ($class, $join_type, $rel, $f_class, $cond, $attrs) = @_;
-  eval "require $f_class";
-  if ($@) {
-    $class->throw_exception($@) unless $@ =~ /Can't locate/;
-  }
-
+  $class->ensure_class_loaded($f_class);
   unless (ref $cond) {
     my ($pri, $too_many) = $class->primary_columns;
     $class->throw_exception( "might_have/has_one can only infer join for a single primary key; ${class} has more" )
       if $too_many;
-    my $f_key;
     my $f_class_loaded = eval { $f_class->columns };
-    my $guess;
+    my ($f_key,$guess);
     if (defined $cond && length $cond) {
       $f_key = $cond;
       $guess = "caller specified foreign key '$f_key'";