what-a-mess
[gitmo/Moose.git] / lib / Moose.pm
index b692b10..6f972bc 100644 (file)
@@ -1,6 +1,4 @@
 
-use lib '/Users/stevan/Projects/CPAN/Class-MOP/Class-MOP/lib';
-
 package Moose;
 
 use strict;
@@ -18,9 +16,10 @@ use Class::MOP;
 
 use Moose::Meta::Class;
 use Moose::Meta::Attribute;
+use Moose::Meta::TypeConstraint;
 
 use Moose::Object;
-use Moose::Util::TypeConstraints ':no_export';
+use Moose::Util::TypeConstraints;
 
 sub import {
        shift;
@@ -32,10 +31,9 @@ sub import {
        Moose::Util::TypeConstraints->import($pkg);
        
        # make a subtype for each Moose class
-    Moose::Util::TypeConstraints::subtype($pkg 
-        => Moose::Util::TypeConstraints::as Object 
-        => Moose::Util::TypeConstraints::where { $_->isa($pkg) }
-       );      
+    subtype $pkg 
+        => as Object 
+        => where { $_->isa($pkg) };    
 
        my $meta;
        if ($pkg->can('meta')) {
@@ -79,7 +77,10 @@ sub import {
                if (exists $options{isa}) {
                    # allow for anon-subtypes here ...
                    if (reftype($options{isa}) && reftype($options{isa}) eq 'CODE') {
-                               $options{type_constraint} = $options{isa};
+                               $options{type_constraint} = Moose::Meta::TypeConstraint->new(
+                                   name            => '__ANON__',
+                                   constraint_code => $options{isa}
+                               );
                        }
                        else {
                            # otherwise assume it is a constraint
@@ -88,10 +89,11 @@ sub import {
                            unless (defined $constraint) {
                                # assume it is a foreign class, and make 
                                # an anon constraint for it 
-                               $constraint = Moose::Util::TypeConstraints::subtype(
-                                   Object => Moose::Util::TypeConstraints::where { $_->isa($constraint) }
-                       );
-                           }
+                               $constraint = Moose::Meta::TypeConstraint->new(
+                                   name            => '__ANON__',
+                                   constraint_code => subtype Object => where { $_->isa($constraint) }
+                               );
+                           }                       
                 $options{type_constraint} = $constraint;
                        }
                }
@@ -222,6 +224,9 @@ this module would not be possible (and it wouldn't have a name).
 =item The basis of the TypeContraints module was Rob Kinyon's idea 
 originally, I just ran with it.
 
+=item Much love to mst & chansen and the whole #moose poose for all the 
+ideas/feature-requests/encouragement
+
 =back
 
 =head1 SEE ALSO