Move having methods to a new superclass - Class::MOP::HasMethods
[gitmo/Class-MOP.git] / lib / Class / MOP.pm
index 1076412..2f6263e 100644 (file)
@@ -12,6 +12,7 @@ use Carp          'confess';
 use Scalar::Util  'weaken', 'reftype', 'blessed';
 use Try::Tiny;
 
+use Class::MOP::HasMethods;
 use Class::MOP::Class;
 use Class::MOP::Attribute;
 use Class::MOP::Method;
@@ -160,68 +161,71 @@ sub _is_valid_class_name {
 # inherit them using _construct_instance
 
 ## --------------------------------------------------------
-## Class::MOP::Package
+## Class::MOP::HasMethods
 
-Class::MOP::Package->meta->add_attribute(
-    Class::MOP::Attribute->new('package' => (
+Class::MOP::HasMethods->meta->add_attribute(
+    Class::MOP::Attribute->new('_methods' => (
         reader   => {
-            # NOTE: we need to do this in order
-            # for the instance meta-object to
-            # not fall into meta-circular death
-            #
+            # NOTE:
             # we just alias the original method
             # rather than re-produce it here
-            'name' => \&Class::MOP::Package::name
+            '_full_method_map' => \&Class::MOP::HasMethods::_full_method_map
         },
+        default => sub { {} }
     ))
 );
 
-Class::MOP::Package->meta->add_attribute(
-    Class::MOP::Attribute->new('namespace' => (
-        reader => {
+Class::MOP::HasMethods->meta->add_attribute(
+    Class::MOP::Attribute->new('method_metaclass' => (
+        reader   => {
             # NOTE:
             # we just alias the original method
             # rather than re-produce it here
-            'namespace' => \&Class::MOP::Package::namespace
+            'method_metaclass' => \&Class::MOP::HasMethods::method_metaclass
         },
-        init_arg => undef,
-        default  => sub { \undef }
+        default  => 'Class::MOP::Method',
     ))
 );
 
-Class::MOP::Package->meta->add_attribute(
-    Class::MOP::Attribute->new('_methods' => (
+Class::MOP::HasMethods->meta->add_attribute(
+    Class::MOP::Attribute->new('wrapped_method_metaclass' => (
         reader   => {
             # NOTE:
             # we just alias the original method
             # rather than re-produce it here
-            '_full_method_map' => \&Class::MOP::Package::_full_method_map
+            'wrapped_method_metaclass' => \&Class::MOP::HasMethods::wrapped_method_metaclass
         },
-        default => sub { {} }
+        default  => 'Class::MOP::Method::Wrapped',
     ))
 );
 
+## --------------------------------------------------------
+## Class::MOP::Package
+
 Class::MOP::Package->meta->add_attribute(
-    Class::MOP::Attribute->new('method_metaclass' => (
+    Class::MOP::Attribute->new('package' => (
         reader   => {
-            # NOTE:
+            # NOTE: we need to do this in order
+            # for the instance meta-object to
+            # not fall into meta-circular death
+            #
             # we just alias the original method
             # rather than re-produce it here
-            'method_metaclass' => \&Class::MOP::Package::method_metaclass
+            'name' => \&Class::MOP::Package::name
         },
-        default  => 'Class::MOP::Method',
     ))
 );
 
 Class::MOP::Package->meta->add_attribute(
-    Class::MOP::Attribute->new('wrapped_method_metaclass' => (
-        reader   => {
+    Class::MOP::Attribute->new('namespace' => (
+        reader => {
             # NOTE:
             # we just alias the original method
             # rather than re-produce it here
-            'wrapped_method_metaclass' => \&Class::MOP::Package::wrapped_method_metaclass
+            'namespace' => \&Class::MOP::Package::namespace
         },
-        default  => 'Class::MOP::Method::Wrapped',
+        init_arg => undef,
+        default  => sub { \undef }
     ))
 );
 
@@ -684,6 +688,14 @@ $_->meta->make_immutable(
     Class::MOP::Method::Wrapped
 /;
 
+$_->meta->make_immutable(
+    inline_constructor  => 0,
+    constructor_name    => undef,
+    inline_accessors => 0,
+) for qw/
+    Class::MOP::HasMethods
+/;
+
 1;
 
 __END__