From: Hans Dieter Pearcey Date: Sat, 28 Mar 2009 22:31:59 +0000 (-0400) Subject: init_meta documentation X-Git-Tag: 0.73_01~37 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a8de959b06fd55b27f3de7ab7da763729916a6c2;p=gitmo%2FMoose.git init_meta documentation --- diff --git a/Changes b/Changes index 1a81ee1..e2e6bfe 100644 --- a/Changes +++ b/Changes @@ -13,6 +13,18 @@ Revision history for Perl extension Moose to fork all of CPAN. (perigrin) - add tests and documentation (perigrin) + * Moose + - Document the fact that init_meta() returns the target class' metaclass + object. (Dieter Pearcey) + + * Moose::Cookbook::Extending::Recipe1 + * Moose::Cookbook::Extending::Recipe2 + * Moose::Cookbook::Extending::Recipe3 + * Moose::Cookbook::Extending::Recipe4 + - Make init_meta() examples explicitly return the metaclass and point out + this fact. (Dieter Pearcey) + + 0.73 Fri, March 29, 2009 * No changes from 0.72_01. diff --git a/lib/Moose.pm b/lib/Moose.pm index 6990a92..222fdb4 100644 --- a/lib/Moose.pm +++ b/lib/Moose.pm @@ -884,6 +884,8 @@ specified by C. This method injects a a C accessor into the class so you can get at this object. It also sets the class's superclass to C, with L as the default. +C returns the metaclass object for C<$class>. + You can specify an alternate metaclass with the C option. For more detail on this topic, see L. diff --git a/lib/Moose/Cookbook/Extending/Recipe1.pod b/lib/Moose/Cookbook/Extending/Recipe1.pod index 89c5c18..17fa59b 100644 --- a/lib/Moose/Cookbook/Extending/Recipe1.pod +++ b/lib/Moose/Cookbook/Extending/Recipe1.pod @@ -196,6 +196,9 @@ subclasses: ); } +NOTE: Make sure that your C returns the metaclass object, just as +C<< Moose->init_meta >> does. + =head2 Extensions as Metaclass (and Base Object) Roles Implementing your extensions as metaclass roles makes your extensions diff --git a/lib/Moose/Cookbook/Extending/Recipe2.pod b/lib/Moose/Cookbook/Extending/Recipe2.pod index d12e56f..36f2e8c 100644 --- a/lib/Moose/Cookbook/Extending/Recipe2.pod +++ b/lib/Moose/Cookbook/Extending/Recipe2.pod @@ -22,12 +22,14 @@ Moose::Cookbook::Extending::Recipe2 - Providing a role for the base object class shift; my %options = @_; - Moose->init_meta(%options); + my $meta = Moose->init_meta(%options); Moose::Util::MetaRole::apply_base_class_roles( for_class => $options{for_class}, roles => ['MooseX::Debugging::Role::Object'], ); + + return $meta; } package MooseX::Debugging::Role::Object; diff --git a/lib/Moose/Cookbook/Extending/Recipe3.pod b/lib/Moose/Cookbook/Extending/Recipe3.pod index 13bb2d0..544a86f 100644 --- a/lib/Moose/Cookbook/Extending/Recipe3.pod +++ b/lib/Moose/Cookbook/Extending/Recipe3.pod @@ -37,7 +37,7 @@ Moose::Cookbook::Extending::Recipe3 - Providing an alternate base object class sub init_meta { shift; - Moose->init_meta( @_, base_class => 'MyApp::Base' ); + return Moose->init_meta( @_, base_class => 'MyApp::Base' ); } =head1 DESCRIPTION diff --git a/lib/Moose/Cookbook/Extending/Recipe4.pod b/lib/Moose/Cookbook/Extending/Recipe4.pod index 30421f1..58c61b5 100644 --- a/lib/Moose/Cookbook/Extending/Recipe4.pod +++ b/lib/Moose/Cookbook/Extending/Recipe4.pod @@ -22,7 +22,7 @@ Moose::Cookbook::Extending::Recipe4 - Acting like Moose.pm and providing sugar M sub init_meta { shift; - Moose->init_meta( @_, metaclass => 'MyApp::Meta::Class' ); + return Moose->init_meta( @_, metaclass => 'MyApp::Meta::Class' ); } sub has_table {