Fix caller determination to work the same way as it did in old school
[gitmo/Moose.git] / lib / Moose / Object.pm
index 9b931d0..56eaff4 100644 (file)
@@ -9,7 +9,7 @@ use if ( not our $__mx_is_compiled ), metaclass => 'Moose::Meta::Class';
 
 use Carp 'confess';
 
-our $VERSION   = '0.52';
+our $VERSION   = '0.56';
 our $AUTHORITY = 'cpan:STEVAN';
 
 sub new {
@@ -74,14 +74,13 @@ sub DESTROY {
 }
 
 # support for UNIVERSAL::DOES ...
-sub DOES {
-    my ( $self, $class_or_role_name ) = @_;
-    if (my $DOES = __PACKAGE__->meta->find_next_method_by_name('DOES')) {
-        return $DOES->body->($self, $class_or_role_name) 
+BEGIN {
+    my $does = UNIVERSAL->can("DOES") ? "SUPER::DOES" : "isa";
+    eval 'sub DOES {
+        my ( $self, $class_or_role_name ) = @_;
+        return $self->'.$does.'($class_or_role_name)
             || $self->does($class_or_role_name);
-    }
-    return $self->isa($class_or_role_name) 
-        || $self->does($class_or_role_name);
+    }';
 }
 
 # new does() methods will be created