Simplify self_result_object argument check in cond resolver
Peter Rabbitson [Sun, 7 Sep 2014 11:11:30 +0000 (13:11 +0200)]
lib/DBIx/Class/ResultSource.pm

index 0636f2e..d046875 100644 (file)
@@ -1881,13 +1881,13 @@ sub _resolve_relationship_condition {
 
   $args->{condition} ||= $rel_info->{cond};
 
-  if (exists $args->{self_result_object}) {
-    $self->throw_exception( "Argument 'self_result_object' must be an object of class '@{[ $self->result_class ]}'" )
-      unless defined blessed $args->{self_result_object};
-
-    $self->throw_exception( "Object '$args->{self_result_object}' must be of class '@{[ $self->result_class ]}'" )
-      unless $args->{self_result_object}->isa($self->result_class);
-  }
+  $self->throw_exception( "Argument 'self_result_object' must be an object of class '@{[ $self->result_class ]}'" )
+    if (
+      exists $args->{self_result_object}
+        and
+      ( ! defined blessed $args->{self_result_object} or ! $args->{self_result_object}->isa($self->result_class) )
+    )
+  ;
 
   my $rel_rsrc = $self->related_source($args->{rel_name});