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;
42 sub { blessed( $_[0] ) && $_[0]->isa($class) }
45 sub has_hand_optimized_type_constraint { 1 }
48 my ($self, $type_name) = @_;
50 return $self->name eq $type_name || $self->is_subtype_of($type_name);
54 my ($self, $type_name) = @_;
56 return 1 if $type_name eq 'Object';
57 return $self->name->isa( $type_name );
68 Moose::Meta::TypeConstraint::Class - Class/TypeConstraint parallel hierarchy
76 =item B<hand_optimized_type_constraint>
78 =item B<has_hand_optimized_type_constraint>
82 =item B<is_subtype_of>
86 Return all the parent types, corresponding to the parent classes.
94 All complex software has bugs lurking in it, and this module is no
95 exception. If you find a bug please either email me, or add the bug
100 Yuval Kogman E<lt>nothingmuch@cpan.orgE<gt>
102 =head1 COPYRIGHT AND LICENSE
104 Copyright 2006-2008 by Infinity Interactive, Inc.
106 L<http://www.iinteractive.com>
108 This library is free software; you can redistribute it and/or modify
109 it under the same terms as Perl itself.