1 package Moose::Util::TypeConstraints::OptimizedConstraints;
6 use Scalar::Util 'blessed', 'looks_like_number';
9 our $AUTHORITY = 'cpan:STEVAN';
12 # Optimized type constraints are XS in Moose.xs
13 XSLoader::load('Moose', '0.39'); # This is a pain... must use the version number of moose
14 # but can't refer to it since Moose may not be loaded.
16 sub Num { !Ref($_[0]) && looks_like_number($_[0]) }
18 sub Int { Defined($_[0]) && !Ref($_[0]) && $_[0] =~ /^-?[0-9]+$/ }
20 sub FileHandle { GlobRef($_[0]) && Scalar::Util::openhandle($_[0]) or ObjectOfType($_[0], "IO::Handle") }
22 sub Role { Object($_[0]) && $_[0]->can('does') }
32 Moose::Util::TypeConstraints::OptimizedConstraints - Optimized constraint
33 bodies for various moose types
37 This file contains the hand optimized versions of Moose type constraints.
75 Makes sure $object->isa($class). Used in anon type constraints.
83 All complex software has bugs lurking in it, and this module is no
84 exception. If you find a bug please either email me, or add the bug
89 Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
90 Konobi E<lt>konobi@cpan.orgE<gt>
92 =head1 COPYRIGHT AND LICENSE
94 Copyright 2006-2008 by Infinity Interactive, Inc.
96 L<http://www.iinteractive.com>
98 This library is free software; you can redistribute it and/or modify
99 it under the same terms as Perl itself.