make re-applying a role to an object instance a no-op. Previously, we ended up making...
[gitmo/Moose.git] / lib / Moose / Meta / Role / Application / ToInstance.pm
index be2ef37..7e5b4d6 100644 (file)
@@ -4,10 +4,9 @@ use strict;
 use warnings;
 use metaclass;
 
-use Carp         'confess';
 use Scalar::Util 'blessed';
 
-our $VERSION   = '0.56';
+our $VERSION   = '0.72';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -23,6 +22,11 @@ my %ANON_CLASSES;
 sub apply {
     my ($self, $role, $object) = @_;
 
+    return
+        if $object->can('meta')
+            && $object->meta->can('does_role')
+            && $object->meta->does_role( $role->name );
+
     my $anon_role_key = (blessed($object) . $role->name);
 
     my $class;
@@ -79,7 +83,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006-2008 by Infinity Interactive, Inc.
+Copyright 2006-2009 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>