From: Matt S Trout Date: Thu, 19 Feb 2009 16:56:31 +0000 (+0000) Subject: switch to :: definitions, explain MooseX::Types usage better X-Git-Tag: 0.71_01~20 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1db88ad4e407d529a9662d6d432cb7ffa0a7f04c;p=gitmo%2FMoose.git switch to :: definitions, explain MooseX::Types usage better --- diff --git a/lib/Moose/Manual/Types.pod b/lib/Moose/Manual/Types.pod index 6236a1a..fcb2d89 100644 --- a/lib/Moose/Manual/Types.pod +++ b/lib/Moose/Manual/Types.pod @@ -178,16 +178,19 @@ you prefix names with some sort of namespace indicator to prevent these sorts of collisions. For example, instead of calling a type "PositiveInt", call it -"MyApp.Type.PositiveInt". +"MyApp::Type::PositiveInt" or "MyApp::Types::PositiveInt" - you may +find it easiest to centralize these definitions in a lib/MyApp/Types.pm +so the other classes in your application can simply do "use MyApp::Types" +and assume that all relevant types have now been defined. -Type names are just strings. We recommend that you I use "::" -as a separator in type names. This can be very confusing, because -class names are I valid type names! Using something else, like a -period, makes it clear that "MyApp::User" is a class and -"MyApp.Type.PositiveInt" is a Moose type defined by your application. +The L module provides namespaced types as functions so that +you can import the names into packages and use them as barewords - i.e. -The L module lets you create bareword aliases to longer -names and also automatically namespaces all the types you define. + has 'foo' => (isa => 'MyApp::Types::PositiveInt'); + +would become + + has 'foo' => (isa => PositiveInt); =head1 COERCION