nuke Sub::Uplevel
[gitmo/MooseX-Types.git] / lib / MooseX / Types.pm
index 853b035..c93591f 100644 (file)
@@ -9,26 +9,25 @@ MooseX::Types - Organise your Moose types in libraries
 #use warnings;
 #use strict;
 
-use Sub::Uplevel;
 use Moose::Util::TypeConstraints;
-use MooseX::Types::Base           ();
-use MooseX::Types::Util           qw( filter_tags );
+use MooseX::Types::Base             ();
+use MooseX::Types::Util             qw( filter_tags );
 use MooseX::Types::UndefinedType;
-use Sub::Install                        qw( install_sub );
+use Sub::Install                    qw( install_sub );
+use Carp                            qw( croak );
 use Moose;
-use namespace::clean;
 
-our $VERSION = 0.01;
+use namespace::clean -except => [qw( meta )];
+
+our $VERSION = 0.05;
 
 my $UndefMsg = q{Action for type '%s' not yet defined in library '%s'};
 
 =head1 SYNOPSIS
 
-  #
-  # Library Definition
-  #
+=head2 Library Definition
+
   package MyLibrary;
-  use strict;
 
   # predeclare our own types
   use MooseX::Types 
@@ -55,9 +54,8 @@ my $UndefMsg = q{Action for type '%s' not yet defined in library '%s'};
 
   1;
 
-  #
-  # Usage
-  #
+=head2 Usage
+
   package Foo;
   use Moose;
   use MyLibrary qw( PositiveInt NegativeInt );
@@ -146,6 +144,12 @@ library which can export all types that come with Moose.
 You will have to define coercions for your types or your library won't
 export a L</to_$type> coercion helper for it.
 
+Note that you currently cannot define types containing C<::>, since 
+exporting would be a problem.
+
+You also don't need to use C<warnings> and C<strict>, since the
+definition of a library automatically exports those.
+
 =head1 LIBRARY USAGE
 
 You can import the L<"type helpers"|/"TYPE HANDLER FUNCTIONS"> of a
@@ -250,6 +254,10 @@ sub import {
     my ($class, %args) = @_;
     my  $callee = caller;
 
+    # everyone should want this
+    strict->import;
+    warnings->import;
+
     # inject base class into new library
     {   no strict 'refs';
         unshift @{ $callee . '::ISA' }, 'MooseX::Types::Base';
@@ -260,6 +268,10 @@ sub import {
         my ($tags, $declare) = filter_tags @orig_declare;
 
         for my $type (@$declare) {
+
+            croak "Cannot create a type containing '::' ($type) at the moment"
+                if $type =~ /::/;
+
             $callee->add_type($type);
             $callee->export_type_into(
                 $callee, $type,