[Moose-commits] r7625 - Moose/trunk/lib/Moose/Cookbook/Meta

autarch at code2.0beta.co.uk autarch at code2.0beta.co.uk
Thu Feb 12 16:01:26 GMT 2009


Author: autarch
Date: 2009-02-12 08:01:25 -0800 (Thu, 12 Feb 2009)
New Revision: 7625

Modified:
   Moose/trunk/lib/Moose/Cookbook/Meta/Recipe4.pod
Log:
Revise meta recipe 4


Modified: Moose/trunk/lib/Moose/Cookbook/Meta/Recipe4.pod
===================================================================
--- Moose/trunk/lib/Moose/Cookbook/Meta/Recipe4.pod	2009-02-12 15:58:13 UTC (rev 7624)
+++ Moose/trunk/lib/Moose/Cookbook/Meta/Recipe4.pod	2009-02-12 16:01:25 UTC (rev 7625)
@@ -27,22 +27,33 @@
 
 =head1 THE METACLASS
 
-The metaclass example really is as simple as the one in the
-synopsis. The trick is getting your classes to use this metaclass, and
-providing some sort of sugar for declaring the table. This is covered
-in L<Moose::Cookbook::Extending::Recipe2>, which shows how to make a
+This really is as simple as the recipe L</SYNOPSIS> shows. The trick
+is getting your classes to use this metaclass, and providing some sort
+of sugar for declaring the table. This is covered in
+L<Moose::Cookbook::Extending::Recipe2>, which shows how to make a
 module like C<Moose.pm> itself, with sugar like C<has_table()>.
 
 =head2 Using this Metaclass in Practice
 
-Using this new "table" attribute is quite simple. Let's say we have a
-class named C<MyApp::User>, we could simply write the following:
+Accessing this new C<table> attribute is quite simple. Given a class
+named C<MyApp::User>, we could simply write the following:
 
   my $table = MyApp::User->meta->table;
 
-As long as MyApp::User has arranged to use C<MyApp::Meta::Class> as
-its metaclass, this method call just works.
+As long as C<MyApp::User> has arranged to use C<MyApp::Meta::Class> as
+its metaclass, this method call just works. If we want to be more
+careful, we can check the metaclass's class:
 
+  $table = MyApp::User->meta->table
+      if MyApp::User->meta->isa('MyApp::Meta::Class');
+
+=head1 CONCLUSION
+
+Creating custom metaclass is trivial. Using it is a little harder, and
+is covered in other recipes. We will also talk about applying traits
+to a class metaclass, which is a more flexible and cooperative
+implementation.
+
 =head1 SEE ALSO
 
 L<Moose::Cookbook::Meta::Recipe5> - The "table" attribute implemented




More information about the Moose-commits mailing list