From: Shawn M Moore Date: Wed, 4 Jun 2008 04:03:01 +0000 (+0000) Subject: Begin adding Mouse::TypeRegistry. All that's there for now is Bool X-Git-Tag: 0.04~97 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=d60c78b9772dafa6db7fa579e94a2f190954aac3;p=gitmo%2FMouse.git Begin adding Mouse::TypeRegistry. All that's there for now is Bool --- diff --git a/lib/Mouse.pm b/lib/Mouse.pm index 1c06330..d2b2fc6 100644 --- a/lib/Mouse.pm +++ b/lib/Mouse.pm @@ -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 index 0000000..3e63cec --- /dev/null +++ b/lib/Mouse/TypeRegistry.pm @@ -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; +