Mouse::Util::blessed
[gitmo/Mouse.git] / lib / Mouse / TypeRegistry.pm
index 4f3125c..a8992c2 100644 (file)
@@ -2,7 +2,9 @@
 package Mouse::TypeRegistry;
 use strict;
 use warnings;
-use Scalar::Util qw/looks_like_number blessed openhandle/;
+
+use Mouse::Util 'blessed';
+use Scalar::Util qw/looks_like_number openhandle/;
 
 no warnings 'uninitialized';
 sub optimized_constraints {
@@ -18,7 +20,7 @@ sub optimized_constraints {
         Num        => sub { !ref($_) && looks_like_number($_) },
         Int        => sub { defined($_) && !ref($_) && /^-?[0-9]+$/ },
         Str        => sub { defined($_) && !ref($_) },
-        ClassName  => sub { 1 },
+        ClassName  => sub { Mouse::is_class_loaded($_) },
         Ref        => sub { ref($_) },
 
         ScalarRef  => sub { ref($_) eq 'SCALAR' },
@@ -42,3 +44,18 @@ sub optimized_constraints {
 
 1;
 
+__END__
+
+=head1 NAME
+
+Mouse::TypeRegistry - simple type constraints
+
+=head1 METHODS
+
+=head2 optimized_constraints -> HashRef[CODE]
+
+Returns the simple type constraints that Mouse understands.
+
+=cut
+
+