X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FManual%2FMOP.pod;h=4398c5316204a727728b0069e85fb401f40055da;hb=31c248bf3c003492975ce3f29dbe81fc6f78f655;hp=7e29a8400e3e2c8acadb3e5225aa08bedb81b124;hpb=967e85912b2294882c010e9de68edd66840e50c5;p=gitmo%2FMoose.git diff --git a/lib/Moose/Manual/MOP.pod b/lib/Moose/Manual/MOP.pod index 7e29a84..4398c53 100644 --- a/lib/Moose/Manual/MOP.pod +++ b/lib/Moose/Manual/MOP.pod @@ -1,14 +1,16 @@ -=pod +package Moose::Manual::MOP; + +# ABSTRACT: The Moose (and Class::MOP) meta API -=head1 NAME +__END__ -Moose::Manual::MOP - The Moose (and Class::MOP) Meta API +=pod =head1 INTRODUCTION Moose provides a powerful introspection API built on top of C. "MOP" stands for Meta-Object Protocol. In plainer -english, a MOP is an API for performing introspection on classes, +English, a MOP is an API for performing introspection on classes, attributes, methods, and so on. In fact, it is C that provides many of Moose's core @@ -24,9 +26,9 @@ method that you're looking for is defined in a C class, rather than Moose itself. The MOP provides more than just I introspection. It also -lets you add attributes, method, apply roles, and much more. In fact, -all of the declarative Moose sugar is simply a thin layer on top of -the MOP API. +lets you add attributes and methods, apply roles, and much more. In +fact, all of the declarative Moose sugar is simply a thin layer on top +of the MOP API. If you want to write Moose extensions, you'll need to learn some of the MOP API. The introspection methods are also handy if you want to @@ -80,7 +82,7 @@ and its parents. You can also get a list of methods: for my $method ( $meta->get_all_methods ) { - print $meth->fully_qualified_name, "\n"; + print $method->fully_qualified_name, "\n"; } Now we're looping over a list of L objects. Note @@ -112,11 +114,7 @@ As an example, we can add a method to a class: Or an attribute: - $meta->add_attribute( - name => 'size', - is => 'rw', - isa => 'Int', - ); + $meta->add_attribute( 'size' => ( is => 'rw', isa => 'Int' ) ); Obviously, this is much more cumbersome than using Perl syntax or Moose sugar for defining methods and attributes, but this API allows @@ -128,41 +126,27 @@ class is immutable, calling any of these update methods will throw an exception. You can make a class mutable again simply by calling C<< -$metaclass->make_mutable >>. Once you're done changing it, you can -restore immutability by calling C<< $metaclass->make_immutable >>. +$meta->make_mutable >>. Once you're done changing it, you can +restore immutability by calling C<< $meta->make_immutable >>. -However, the most common use for this part of of the meta API is as +However, the most common use for this part of the meta API is as part of Moose extensions. These extensions should assume that they are being run before you make a class immutable. =head1 GOING FURTHER -If you're interested in extending moose, we recommend reading all of +If you're interested in extending Moose, we recommend reading all of the "Meta" and "Extending" recipes in the L. Those recipes show various practical applications of the MOP. If you'd like to write your own extensions, one of the best ways to learn more about this is to look at other similar extensions to see how they work. You'll probably also need to read various API docs, -including the docs for the various Moose::Meta::* classes and the -C distribution. +including the docs for the various C and +C classes. Finally, we welcome questions on the Moose mailing list and IRC. Information on the mailing list, IRC, and more references can be found in the L. -=head1 AUTHOR - -Dave Rolsky Eautarch@urth.orgE and Stevan Little -Estevan@iinteractive.comE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2009 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. - =cut