2 package Mouse::TypeRegistry;
6 use Mouse::Util qw/blessed looks_like_number openhandle/;
8 no warnings 'uninitialized';
9 sub optimized_constraints {
14 !defined($_) || $_ eq "" || "$_" eq '1' || "$_" eq '0'
16 Undef => sub { !defined($_) },
17 Defined => sub { defined($_) },
18 Value => sub { defined($_) && !ref($_) },
19 Num => sub { !ref($_) && looks_like_number($_) },
20 Int => sub { defined($_) && !ref($_) && /^-?[0-9]+$/ },
21 Str => sub { defined($_) && !ref($_) },
22 ClassName => sub { Mouse::is_class_loaded($_) },
23 Ref => sub { ref($_) },
25 ScalarRef => sub { ref($_) eq 'SCALAR' },
26 ArrayRef => sub { ref($_) eq 'ARRAY' },
27 HashRef => sub { ref($_) eq 'HASH' },
28 CodeRef => sub { ref($_) eq 'CODE' },
29 RegexpRef => sub { ref($_) eq 'Regexp' },
30 GlobRef => sub { ref($_) eq 'GLOB' },
37 && $_->isa("IO::Handle")
40 Object => sub { blessed($_) && blessed($_) ne 'Regexp' },
50 Mouse::TypeRegistry - simple type constraints
54 =head2 optimized_constraints -> HashRef[CODE]
56 Returns the simple type constraints that Mouse understands.