1 package Moose::Meta::TypeConstraint::Class;
7 use Scalar::Util 'blessed';
8 use Moose::Util::TypeConstraints ();
10 our $VERSION = '0.01';
11 our $AUTHORITY = 'cpan:STEVAN';
13 use base 'Moose::Meta::TypeConstraint';
17 my $self = $class->meta->new_object(@_,
18 parent => Moose::Util::TypeConstraints::find_type_constraint('Object')
20 $self->compile_type_constraint()
21 unless $self->_has_compiled_type_constraint;
31 # Hmm, should this be find_or_create_type_constraint?
32 # What do you think nothingmuch??
34 Moose::Util::TypeConstraints::find_type_constraint($_)
35 } $self->name->meta->superclasses,
39 sub hand_optimized_type_constraint {
41 my $class = $self->name;
43 Moose::Util::TypeConstraints::OptimizedConstraints::ObjectOfType($_[0], $class)
47 sub has_hand_optimized_type_constraint { 1 }
50 my ($self, $type_name) = @_;
52 return $self->name eq $type_name || $self->is_subtype_of($type_name);
56 my ($self, $type_name) = @_;
58 return 1 if $type_name eq 'Object';
59 return $self->name->isa( $type_name );
70 Moose::Meta::TypeConstraint::Class - Class/TypeConstraint parallel hierarchy
78 =item B<hand_optimized_type_constraint>
80 =item B<has_hand_optimized_type_constraint>
84 =item B<is_subtype_of>
88 Return all the parent types, corresponding to the parent classes.
96 All complex software has bugs lurking in it, and this module is no
97 exception. If you find a bug please either email me, or add the bug
102 Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
104 =head1 COPYRIGHT AND LICENSE
106 Copyright 2006-2008 by Infinity Interactive, Inc.
108 L<http://www.iinteractive.com>
110 This library is free software; you can redistribute it and/or modify
111 it under the same terms as Perl itself.