fix restricted class existence check to work on perl 5.18
[dbsrgits/DBIx-Class-Schema-RestrictWithObject.git] / lib / DBIx / Class / Schema / RestrictWithObject.pm
index 05f3477..494beef 100644 (file)
@@ -136,10 +136,10 @@ Return an appropriate class name for a restricted class of type $type.
 sub _get_restricted_class {
   my ($self, $type, $target) = @_;
   my $r_class = join('::', $target, '__RestrictedWithObject');
-  unless (eval { $r_class->can('can') }) {
-    my $r_comp = join(
-      '::', 'DBIx::Class::Schema::RestrictWithObject::RestrictComp', $type
-    );
+  my $r_comp = join(
+    '::', 'DBIx::Class::Schema::RestrictWithObject::RestrictComp', $type
+  );
+  unless ($r_class->isa($r_comp)) {
     $self->inject_base($r_class, $r_comp, $target);
   }
   return $r_class;