From: Dave Rolsky Date: Thu, 12 Feb 2009 16:01:25 +0000 (+0000) Subject: Revise meta recipe 4 X-Git-Tag: 0.69~16 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ccea63ce44db05da6bbc1a51a136ead4c275f8e4;p=gitmo%2FMoose.git Revise meta recipe 4 --- diff --git a/lib/Moose/Cookbook/Meta/Recipe4.pod b/lib/Moose/Cookbook/Meta/Recipe4.pod index b24874b..cfaf693 100644 --- a/lib/Moose/Cookbook/Meta/Recipe4.pod +++ b/lib/Moose/Cookbook/Meta/Recipe4.pod @@ -27,21 +27,32 @@ the table might be an object describing the table. =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, which shows how to make a +This really is as simple as the recipe L 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, which shows how to make a module like C itself, with sugar like C. =head2 Using this Metaclass in Practice -Using this new "table" attribute is quite simple. Let's say we have a -class named C, we could simply write the following: +Accessing this new C attribute is quite simple. Given a class +named C, we could simply write the following: my $table = MyApp::User->meta->table; -As long as MyApp::User has arranged to use C as -its metaclass, this method call just works. +As long as C has arranged to use C 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