Begin adding Mouse::TypeRegistry. All that's there for now is Bool
Shawn M Moore [Wed, 4 Jun 2008 04:03:01 +0000 (04:03 +0000)]
lib/Mouse.pm
lib/Mouse/TypeRegistry.pm [new file with mode: 0644]

index 1c06330..d2b2fc6 100644 (file)
@@ -12,6 +12,7 @@ use Scalar::Util 'blessed';
 use Mouse::Attribute;
 use Mouse::Class;
 use Mouse::Object;
+use Mouse::TypeRegistry;
 
 do {
     my $CALLER;
diff --git a/lib/Mouse/TypeRegistry.pm b/lib/Mouse/TypeRegistry.pm
new file mode 100644 (file)
index 0000000..3e63cec
--- /dev/null
@@ -0,0 +1,33 @@
+#!/usr/bin/env perl
+package Mouse::TypeRegistry;
+use strict;
+use warnings;
+
+sub optimized_constraints {
+    return {
+        Any        => sub { 1 },
+        Item       => sub { 1 },
+        Bool       => sub {
+            !defined($_) || $_ eq "" || "$_" eq '1' || "$_" eq '0'
+        },
+        Undef      => sub { 1 },
+        Defined    => sub { 1 },
+        Value      => sub { 1 },
+        Num        => sub { 1 },
+        Int        => sub { 1 },
+        Str        => sub { 1 },
+        ClassName  => sub { 1 },
+        Ref        => sub { 1 },
+        ScalarRef  => sub { 1 },
+        ArrayRef   => sub { 1 },
+        HashRef    => sub { 1 },
+        CodeRef    => sub { 1 },
+        RegexpRef  => sub { 1 },
+        GlobRef    => sub { 1 },
+        FileHandle => sub { 1 },
+        Object     => sub { 1 },
+    };
+}
+
+1;
+