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
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__
=head1 SYNOPSIS
- use Class::MOP ':universal';
-
- package Foo;
-
- Foo->meta->add_method('foo' => sub { ... });
+ # ...
=head1 DESCRIPTON
=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
=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