More indirect call removals: the second part of 77c3a5dc
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / CDBICompat / Relationships.pm
index 05afe74..a5bfa5e 100644 (file)
@@ -3,11 +3,13 @@ package # hide from PAUSE
 
 use strict;
 use warnings;
-use base 'Class::Data::Inheritable';
+use base 'DBIx::Class';
 
 use Clone;
 use DBIx::Class::CDBICompat::Relationship;
+use Scalar::Util 'blessed';
 use DBIx::Class::_Util qw(quote_sub perlstring);
+use namespace::clean;
 
 __PACKAGE__->mk_classdata('__meta_info' => {});
 
@@ -127,7 +129,7 @@ sub has_many {
 
   if (@f_method) {
     quote_sub "${class}::${rel}", sprintf( <<'EOC', perlstring $rel), { '$rf' => \sub { my $o = shift; $o = $o->$_ for @f_method; $o } };
-      my $rs = shift->search_related( %s => @_);
+      my $rs = shift->related_resultset(%s)->search_rs( @_);
       $rs->{attrs}{record_filter} = $rf;
       return (wantarray ? $rs->all : $rs);
 EOC
@@ -200,15 +202,18 @@ sub search {
                   : undef());
   if (ref $where eq 'HASH') {
     foreach my $key (keys %$where) { # has_a deflation hack
-      $where->{$key} = ''.$where->{$key}
-        if eval { $where->{$key}->isa('DBIx::Class') };
+      $where->{$key} = ''.$where->{$key} if (
+        defined blessed $where->{$key}
+          and
+        $where->{$key}->isa('DBIx::Class')
+      );
     }
   }
   $self->next::method($where, $attrs);
 }
 
 sub new_related {
-  return shift->search_related(shift)->new_result(shift);
+  return shift->search_related(shift)->new_result(@_);
 }
 
 =head1 FURTHER QUESTIONS?