updating the test numbers and adding the CountingClass test
[gitmo/Class-MOP.git] / lib / Class / MOP.pm
index 5221858..4c56ef7 100644 (file)
@@ -21,9 +21,25 @@ sub import {
             Class::MOP::Class->initialize(blessed($_[0]) || $_[0]) 
         };
     }
+    else {
+        my $pkg = caller();
+        no strict 'refs';
+        *{$pkg . '::' . $_[0]} = sub { 
+            Class::MOP::Class->initialize(blessed($_[0]) || $_[0]) 
+        };        
+    }
 }
 
-## Bootstrapping
+## ----------------------------------------------------------------------------
+## Bootstrapping 
+## ----------------------------------------------------------------------------
+## The code below here is to bootstrap our MOP with itself. This is also 
+## sometimes called "tying the knot". By doing this, we make it much easier
+## to extend the MOP through subclassing and such since now you can use the
+## MOP itself to extend itself. 
+## 
+## Yes, I know, thats weird and insane, but it's a good thing, trust me :)
+## ---------------------------------------------------------------------------- 
 
 # We need to add in the meta-attributes here so that 
 # any subclass of Class::MOP::* will be able to 
@@ -73,18 +89,6 @@ Class::MOP::Attribute->meta->add_method('new' => sub {
     bless $class->meta->construct_instance(name => $name, %options) => $class;
 });
 
-# NOTE: (meta-circularity)
-# This is how we "tie the knot" for the class
-# meta-objects. This is used to construct the
-# Class::MOP::Class instances after all the 
-# bootstrapping is complete.
-Class::MOP::Class->meta->add_method('construct_class_instance' => sub {
-    my ($class, $package_name) = @_;
-    (defined $package_name && $package_name)
-        || confess "You must pass a package name";      
-    bless Class::MOP::Class->meta->construct_instance(':pkg' => $package_name) => blessed($class) || $class        
-});
-
 1;
 
 __END__
@@ -97,11 +101,7 @@ Class::MOP - A Meta Object Protocol for Perl 5
 
 =head1 SYNOPSIS
 
-  use Class::MOP ':universal';
-  
-  package Foo;
-  
-  Foo->meta->add_method('foo' => sub { ... });
+  # ... 
 
 =head1 DESCRIPTON
 
@@ -217,6 +217,12 @@ See L<Class::MOP::Method> for more details.
 
 =back
 
+head1 BUGS
+
+All complex software has bugs lurking in it, and this module is no 
+exception. If you find a bug please either email me, or add the bug
+to cpan-RT.
+
 =head1 SEE ALSO
 
 =head2 Books
@@ -227,13 +233,15 @@ See L<Class::MOP::Method> for more details.
 
 =item "Advances in Object-Oriented Metalevel Architecture and Reflection"
 
+=item "Putting MetaClasses to Work"
+
 =back
 
 =head2 Prior Art
 
 =over 4
 
-=item The Perl 6 MetaModel work
+=item The Perl 6 MetaModel work in the Pugs project
 
 =over 4