From: Dave Rolsky Date: Thu, 29 Jan 2009 18:20:10 +0000 (+0000) Subject: Add a mention of load order issues X-Git-Tag: 0.66~27^2~8 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=ca680d1f1af9648673493bc337d31cf1c1601557;p=gitmo%2FMoose.git Add a mention of load order issues --- diff --git a/lib/Moose/Manual/Types.pod b/lib/Moose/Manual/Types.pod index aa9c73b..8d6d8f0 100644 --- a/lib/Moose/Manual/Types.pod +++ b/lib/Moose/Manual/Types.pod @@ -396,6 +396,25 @@ keyword. $self->say("Good morning ${name}!"); } +=head1 LOAD ORDER ISSUES + +Because Moose types are defined at runtime, you can sometimes run into +issues with load order. In particular, you may sometimes want to use a +class's type constraint before it exists. + +We recommend several things. First, define I of your custom types +in one module, C. Second, load this module in all of +your other modules. + +If you are still having load order problems, you can make use of the +C function exported by +L: + + my $type = find_type_constraint('MyApp::User') || class_type('MyApp::User'); + +This sort of "find or create" logic is simple to write, and will let +you work around load order issues. + =head1 AUTHOR Dave Rolsky Eautarch@urth.orgE