Make ->does, ->DOES safe on old perls (RT#100866)
[p5sagit/Safe-Isa.git] / lib / Safe / Isa.pm
index e4f3fea..bdd93e5 100644 (file)
@@ -15,6 +15,7 @@ our $_call_if_object = sub {
   # we gratuitously break modules like Scalar::Defer, which would be
   # un-perlish.
   return unless blessed($obj);
+  return $obj->isa(@_) if lc($method) eq 'does' and not $obj->can($method);
   return $obj->$method(@_);
 };
 
@@ -23,6 +24,11 @@ our ($_isa, $_can, $_does, $_DOES) = map {
   sub { my $obj = shift; $obj->$_call_if_object($method => @_) }
 } qw(isa can does DOES);
 
+1;
+__END__
+
+=pod
+
 =head1 NAME
 
 Safe::Isa - Call isa, can, does and DOES safely on things that may not be objects