From: D. Ilmari Mannsåker Date: Fri, 14 Jun 2013 13:55:41 +0000 (+0100) Subject: fix restricted class existence check to work on perl 5.18 X-Git-Tag: 0.0002~2 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2390a52b728f0cadcc067326b1cbaa0aa428711f;p=dbsrgits%2FDBIx-Class-Schema-RestrictWithObject.git fix restricted class existence check to work on perl 5.18 In 5.18 every class name inherits from UNIVERSAL and thus ->can('can'), whether it's been defined in any way or not. Instead, check if the class alredy inherits from the correct restricting component. --- diff --git a/Changes b/Changes index c06c3e0..f9f7130 100644 --- a/Changes +++ b/Changes @@ -1,5 +1,6 @@ 0.00002 -reuse coderefs from can + -fix restricted class existence check to work on perl 5.18 0.00001 -initial release diff --git a/lib/DBIx/Class/Schema/RestrictWithObject.pm b/lib/DBIx/Class/Schema/RestrictWithObject.pm index 05f3477..494beef 100644 --- a/lib/DBIx/Class/Schema/RestrictWithObject.pm +++ b/lib/DBIx/Class/Schema/RestrictWithObject.pm @@ -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;