Mixins no longer inherit from CMOP::Object.
Dave Rolsky [Mon, 28 Dec 2009 17:14:24 +0000 (11:14 -0600)]
They now inherit from CMOP::Mixin, which just provides a ->meta method.

lib/Class/MOP.pm
lib/Class/MOP/Mixin.pm [new file with mode: 0644]
lib/Class/MOP/Mixin/AttributeCore.pm
lib/Class/MOP/Mixin/HasAttributes.pm
lib/Class/MOP/Mixin/HasMethods.pm
lib/Class/MOP/Package.pm
t/000_load.t
t/010_self_introspection.t

index 01a619e..bad986d 100644 (file)
@@ -699,6 +699,7 @@ $_->meta->make_immutable(
     constructor_name    => undef,
     inline_accessors => 0,
 ) for qw/
+    Class::MOP::Mixin
     Class::MOP::Mixin::AttributeCore
     Class::MOP::Mixin::HasAttributes
     Class::MOP::Mixin::HasMethods
diff --git a/lib/Class/MOP/Mixin.pm b/lib/Class/MOP/Mixin.pm
new file mode 100644 (file)
index 0000000..b7c20d1
--- /dev/null
@@ -0,0 +1,13 @@
+package Class::MOP::Mixin;
+
+use strict;
+use warnings;
+
+use Scalar::Util 'blessed';
+
+sub meta {
+    require Class::MOP::Class;
+    Class::MOP::Class->initialize( blessed( $_[0] ) || $_[0] );
+}
+
+1;
index f1b9089..4f47112 100644 (file)
@@ -9,7 +9,7 @@ our $VERSION = '0.97';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
-use base 'Class::MOP::Object';
+use base 'Class::MOP::Mixin';
 
 sub has_accessor        { defined $_[0]->{'accessor'} }
 sub has_reader          { defined $_[0]->{'reader'} }
index 2cac5e2..d56c629 100644 (file)
@@ -6,7 +6,7 @@ use warnings;
 use Carp         'confess';
 use Scalar::Util 'blessed';
 
-use base 'Class::MOP::Object';
+use base 'Class::MOP::Mixin';
 
 sub _attribute_map      { $_[0]->{'attributes'} }
 sub attribute_metaclass { $_[0]->{'attribute_metaclass'} }
index 75cb51a..82abbcc 100644 (file)
@@ -7,7 +7,7 @@ use Scalar::Util 'blessed';
 use Carp         'confess';
 use Sub::Name    'subname';
 
-use base 'Class::MOP::Object';
+use base 'Class::MOP::Mixin';
 
 sub method_metaclass         { $_[0]->{'method_metaclass'}            }
 sub wrapped_method_metaclass { $_[0]->{'wrapped_method_metaclass'}    }
index e9f388c..0fd9fdc 100644 (file)
@@ -11,7 +11,7 @@ our $VERSION   = '0.97';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
-use base 'Class::MOP::Mixin::HasMethods';
+use base 'Class::MOP::Object', 'Class::MOP::Mixin::HasMethods';
 
 # creation ...
 
index 4e0fe9d..e6abf02 100644 (file)
@@ -5,6 +5,7 @@ use Test::More;
 
 BEGIN {
     use_ok('Class::MOP');
+    use_ok('Class::MOP::Mixin');
     use_ok('Class::MOP::Mixin::AttributeCore');
     use_ok('Class::MOP::Mixin::HasAttributes');
     use_ok('Class::MOP::Mixin::HasMethods');
@@ -32,6 +33,7 @@ my %METAS = (
     'Class::MOP::Method::Accessor'  => Class::MOP::Method::Accessor->meta,
     'Class::MOP::Method::Constructor' =>
         Class::MOP::Method::Constructor->meta,
+    'Class::MOP::Mixin'   => Class::MOP::Mixin->meta,
     'Class::MOP::Mixin::AttributeCore'   => Class::MOP::Mixin::AttributeCore->meta,
     'Class::MOP::Mixin::HasAttributes'   => Class::MOP::Mixin::HasAttributes->meta,
     'Class::MOP::Mixin::HasMethods'      => Class::MOP::Mixin::HasMethods->meta,
@@ -83,6 +85,7 @@ is_deeply(
         Class::MOP::Method::Generated->meta,
         Class::MOP::Method::Inlined->meta,
         Class::MOP::Method::Wrapped->meta,
+        Class::MOP::Mixin->meta,
         Class::MOP::Mixin::AttributeCore->meta,
         Class::MOP::Mixin::HasAttributes->meta,
         Class::MOP::Mixin::HasMethods->meta,
@@ -101,6 +104,7 @@ is_deeply(
             Class::MOP::Class
             Class::MOP::Class::Immutable::Class::MOP::Class
             Class::MOP::Class::Immutable::Trait
+            Class::MOP::Mixin
             Class::MOP::Mixin::AttributeCore
             Class::MOP::Mixin::HasAttributes
             Class::MOP::Mixin::HasMethods
index cb95b6b..2f0f17b 100644 (file)
@@ -324,10 +324,11 @@ is_deeply(
         Class::MOP::Class
         Class::MOP::Module
         Class::MOP::Package
-        Class::MOP::Mixin::HasMethods
         Class::MOP::Object
+        Class::MOP::Mixin::HasMethods
+        Class::MOP::Mixin
         Class::MOP::Mixin::HasAttributes
-        Class::MOP::Object
+        Class::MOP::Mixin
     / ],
     '... Class::MOP::Class->class_precedence_list == [ Class::MOP::Class Class::MOP::Module Class::MOP::Package ]');