bump version to 0.73_01
[gitmo/Moose.git] / lib / Moose / Util / TypeConstraints / OptimizedConstraints.pm
index 5a6607b..b2d3656 100644 (file)
@@ -3,9 +3,11 @@ package Moose::Util::TypeConstraints::OptimizedConstraints;
 use strict;
 use warnings;
 
+use Class::MOP;
 use Scalar::Util 'blessed', 'looks_like_number';
 
-our $VERSION   = '0.01';
+our $VERSION   = '0.73_01';
+$VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
 sub Value { defined($_[0]) && !ref($_[0]) }
@@ -18,15 +20,12 @@ sub Num { !ref($_[0]) && looks_like_number($_[0]) }
 
 sub Int { defined($_[0]) && !ref($_[0]) && $_[0] =~ /^-?[0-9]+$/ }
 
-{
-    no warnings 'uninitialized';
-    sub ScalarRef { ref($_[0]) eq 'SCALAR' }
-    sub ArrayRef  { ref($_[0]) eq 'ARRAY'  }
-    sub HashRef   { ref($_[0]) eq 'HASH'   }
-    sub CodeRef   { ref($_[0]) eq 'CODE'   }
-    sub RegexpRef { ref($_[0]) eq 'Regexp' }
-    sub GlobRef   { ref($_[0]) eq 'GLOB'   }
-}
+sub ScalarRef { ref($_[0]) eq 'SCALAR' }
+sub ArrayRef  { ref($_[0]) eq 'ARRAY'  }
+sub HashRef   { ref($_[0]) eq 'HASH'   }
+sub CodeRef   { ref($_[0]) eq 'CODE'   }
+sub RegexpRef { ref($_[0]) eq 'Regexp' }
+sub GlobRef   { ref($_[0]) eq 'GLOB'   }
 
 sub FileHandle { ref($_[0]) eq 'GLOB' && Scalar::Util::openhandle($_[0]) or blessed($_[0]) && $_[0]->isa("IO::Handle") }
 
@@ -34,6 +33,15 @@ sub Object { blessed($_[0]) && blessed($_[0]) ne 'Regexp' }
 
 sub Role { blessed($_[0]) && $_[0]->can('does') }
 
+sub ClassName {
+    return Class::MOP::is_class_loaded( $_[0] );
+}
+
+sub RoleName {
+    ClassName($_[0])
+    && (Class::MOP::class_of($_[0]) || return)->isa('Moose::Meta::Role')
+}
+
 # NOTE:
 # we have XS versions too, ...
 # 04:09 <@konobi> nothingmuch: konobi.co.uk/code/utilsxs.tar.gz
@@ -52,39 +60,44 @@ bodies for various moose types
 
 =head1 DESCRIPTION
 
-This file contains the hand optimized versions of Moose type constraints.
+This file contains the hand optimized versions of Moose type constraints, 
+no user serviceable parts inside.
 
 =head1 FUNCTIONS
 
 =over 4
 
-=item Value
+=item C<Value>
+
+=item C<Ref>
+
+=item C<Str>
 
-=item Ref
+=item C<Num>
 
-=item Str
+=item C<Int>
 
-=item Num
+=item C<ScalarRef>
 
-=item Int
+=item C<ArrayRef>
 
-=item ScalarRef
+=item C<HashRef>
 
-=item ArrayRef
+=item C<CodeRef>
 
-=item HashRef
+=item C<RegexpRef>
 
-=item CodeRef
+=item C<GlobRef>
 
-=item RegexpRef
+=item C<FileHandle>
 
-=item GlobRef
+=item C<Object>
 
-=item FileHandle
+=item C<Role>
 
-=item Object
+=item C<ClassName>
 
-=item Role
+=item C<RoleName>
 
 =back
 
@@ -100,7 +113,7 @@ Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006-2008 by Infinity Interactive, Inc.
+Copyright 2007-2009 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>