add cache attribute to M::Meta::Class->create_anon_class
[gitmo/Moose.git] / lib / Moose / Role.pm
index 6f314b7..67347a3 100644 (file)
@@ -11,7 +11,7 @@ use Sub::Name    'subname';
 use Data::OptList;
 use Sub::Exporter;
 
-our $VERSION   = '0.07';
+our $VERSION   = '0.08';
 our $AUTHORITY = 'cpan:STEVAN';
 
 use Moose       ();
@@ -31,8 +31,8 @@ use Moose::Util::TypeConstraints;
         # make a subtype for each Moose class
         subtype $role
             => as 'Role'
-            => where { $_->does($role) }
-            => optimize_as { blessed($_[0]) && $_[0]->can('does') && $_[0]->does($role) }
+            => where { Moose::Util::does_role($_, $role) }
+            => optimize_as { blessed($_[0]) && Moose::Util::does_role($_[0], $role) }
         unless find_type_constraint($role);
 
         my $meta;
@@ -154,6 +154,10 @@ use Moose::Util::TypeConstraints;
           && defined $_[1]->{into_level} ? caller( $_[1]->{into_level} )
           :                                caller();
 
+        # this works because both pragmas set $^H (see perldoc perlvar)
+        # which affects the current compilation - i.e. the file who use'd
+        # us - which is why we don't need to do anything special to make
+        # it affect that file rather than this one (which is already compiled)
 
         strict->import;
         warnings->import;