added a tags directory for releases
[gitmo/MooseX-Types.git] / t / lib / DecoratorLibrary.pm
index 180a959..8361866 100644 (file)
@@ -10,23 +10,11 @@ use MooseX::Types
         MyHashRefOfStr
         StrOrArrayRef
         AtLeastOneInt
+        Jobs
+        SubOfMyArrayRefInt01
+        BiggerInt
     )];
 
-## Some questionable messing around
-    sub my_subtype {
-        my ($subtype, $basetype, @rest) = @_;
-        return subtype($subtype, $basetype, shift @rest, shift @rest);
-    }
-    
-    sub my_from {
-        return @_;
-        
-    }
-    sub my_as {
-        return @_;
-    }
-## End
-
 subtype MyArrayRefBase,
     as ArrayRef;
     
@@ -37,6 +25,27 @@ coerce MyArrayRefBase,
 subtype MyArrayRefInt01,
     as ArrayRef[Int];
 
+subtype BiggerInt,
+    as Int,
+    where {$_>10};
+
+## We can change this when the .61 Moose comes out.  When that happens we will
+## have the correct patch to Moose::Meta::TypeConstraint::Parameterized to let
+## us support parameterizing parameterized subtypes.  When we get this we can
+## then replace the where clause with:
+
+    ##as MyArrayRefInt01[BiggerInt];
+
+subtype SubOfMyArrayRefInt01,
+    as MyArrayRefInt01,
+    where {
+        my $ok_or_not = 1;
+        foreach my $int (@$_) {
+            $ok_or_not = $int>10 ? 1:0
+             if $ok_or_not;
+        } $ok_or_not;
+    };
+
 coerce MyArrayRefInt01,
     from Str,
     via {[split('\.',$_)]},
@@ -68,5 +77,8 @@ subtype StrOrArrayRef,
 subtype AtLeastOneInt,
     as ArrayRef[Int],
     where { @$_ > 0 };
-
+    
+enum Jobs,
+    (qw/Programming Teaching Banking/);
+    
 1;