Move a CDBI escape to the CDBI class hierarchy
Peter Rabbitson [Sat, 12 Jul 2014 11:52:45 +0000 (13:52 +0200)]
lib/DBIx/Class/CDBICompat/Relationships.pm
lib/DBIx/Class/Relationship/Base.pm

index 58b29e0..3ce3ef5 100644 (file)
@@ -200,4 +200,8 @@ sub search {
   $self->next::method($where, $attrs);
 }
 
+sub new_related {
+  return shift->search_related(shift)->new_result(shift);
+}
+
 1;
index e2f6224..2868250 100644 (file)
@@ -641,8 +641,6 @@ sub new_related {
   # sanity check - currently throw when a complex coderef rel is encountered
   # FIXME - should THROW MOAR!
 
-  if (ref $self) {  # cdbi calls this as a class method, /me vomits
-
     my $rsrc = $self->result_source;
     my $rel_info = $rsrc->relationship_info($rel)
       or $self->throw_exception( "No such relationship '$rel'" );
@@ -664,7 +662,6 @@ sub new_related {
         map { "'$_'" } @unspecified_rel_condition_chunks
       ));
     }
-  }
 
   return $self->search_related($rel)->new_result($values);
 }