bump version to 0.79
[gitmo/Moose.git] / lib / Moose / Util / MetaRole.pm
index 217d6bf..e44cba6 100644 (file)
@@ -3,7 +3,7 @@ package Moose::Util::MetaRole;
 use strict;
 use warnings;
 
-our $VERSION   = '0.64';
+our $VERSION   = '0.79';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
@@ -16,8 +16,9 @@ sub apply_metaclass_roles {
 
     my $for = $options{for_class};
 
-    my %old_classes
-        = map { $_ => $for->meta->$_ } grep { $for->meta->can($_) } @Classes;
+    my %old_classes = map { $_ => Class::MOP::class_of($for)->$_ }
+                      grep { Class::MOP::class_of($for)->can($_) }
+                      @Classes;
 
     my $meta = _make_new_metaclass( $for, \%options );
 
@@ -42,19 +43,19 @@ sub _make_new_metaclass {
     my $for     = shift;
     my $options = shift;
 
-    return $for->meta()
+    return Class::MOP::class_of($for)
         unless grep { exists $options->{ $_ . '_roles' } }
             qw(
             metaclass
             attribute_metaclass
             method_metaclass
+            wrapped_method_metaclass
             instance_metaclass
     );
 
+    my $old_meta = Class::MOP::class_of($for);
     my $new_metaclass
-        = _make_new_class( ref $for->meta(), $options->{metaclass_roles} );
-
-    my $old_meta = $for->meta();
+        = _make_new_class( ref $old_meta, $options->{metaclass_roles} );
 
     # This could get called for a Moose::Meta::Role as well as a Moose::Meta::Class
     my %classes = map {
@@ -64,6 +65,7 @@ sub _make_new_metaclass {
         qw(
         attribute_metaclass
         method_metaclass
+        wrapped_method_metaclass
         instance_metaclass
     );
 
@@ -75,7 +77,7 @@ sub apply_base_class_roles {
 
     my $for = $options{for_class};
 
-    my $meta = $for->meta();
+    my $meta = Class::MOP::class_of($for);
 
     my $new_base = _make_new_class(
         $for,
@@ -118,12 +120,9 @@ Moose::Util::MetaRole - Apply roles to any metaclass, as well as the object base
 
   package MyApp::Moose;
 
-  use strict;
-  use warnings;
-
   use Moose ();
   use Moose::Exporter;
-  use Moose::Util::Meta::Role;
+  use Moose::Util::MetaRole;
 
   use MyApp::Role::Meta::Class;
   use MyApp::Role::Meta::Method::Constructor;
@@ -199,6 +198,8 @@ This specifies the class for which to alter the meta classes.
 
 =item * method_metaclass_roles => \@roles
 
+=item * wrapped_method_metaclass_roles => \@roles
+
 =item * instance_metaclass_roles => \@roles
 
 =item * constructor_class_roles => \@roles
@@ -215,51 +216,13 @@ once.
 
 This function will apply the specified roles to the object's base class.
 
-=head1 PROBLEMS WITH METACLASS ROLES AND SUBCLASS
-
-Because of the way this module works, there is an ordering problem
-which occurs in certain situations. This sequence of events causes an
-error:
-
-=over 4
-
-=item 1.
-
-There is a class (ClassA) which uses some extension(s) that apply
-roles to the metaclass.
-
-=item 2.
-
-You have another class (ClassB) which wants to subclass ClassA and
-apply some more extensions.
-
-=back
-
-Normally, the call to C<extends> will happen at run time, I<after> the
-additional extensions are applied. This causes an error when we try to
-make the metaclass for ClassB compatible with the metaclass for
-ClassA.
-
-We hope to be able to fix this in the future.
-
-For now the workaround is for ClassB to make sure it extends ClassA
-I<before> it loads extensions:
-
-  package ClassB;
-
-  use Moose;
-
-  BEGIN { extends 'ClassA' }
-
-  use MooseX::SomeExtension;
-
 =head1 AUTHOR
 
 Dave Rolsky E<lt>autarch@urth.orgE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2008 by Infinity Interactive, Inc.
+Copyright 2009 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>