X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeConstraint%2FRole.pm;h=a69e6cd168e8668b755c06dc3a394d21f1fd7934;hb=3975b592007cd8f44368f71cedc60fba86b5a1f2;hp=3508cc4139337dbf0375e3355fe15e94c2e2d4f5;hpb=9039e8ec60c872fa009efedd3b7b311128d1fc4b;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeConstraint/Role.pm b/lib/Moose/Meta/TypeConstraint/Role.pm index 3508cc4..a69e6cd 100644 --- a/lib/Moose/Meta/TypeConstraint/Role.pm +++ b/lib/Moose/Meta/TypeConstraint/Role.pm @@ -4,24 +4,37 @@ use strict; use warnings; use metaclass; +use B; use Scalar::Util 'blessed'; use Moose::Util::TypeConstraints (); -our $VERSION = '0.89_01'; -$VERSION = eval $VERSION; -our $AUTHORITY = 'cpan:STEVAN'; - use base 'Moose::Meta::TypeConstraint'; __PACKAGE__->meta->add_attribute('role' => ( reader => 'role', )); +my $inliner = sub { + my $self = shift; + my $val = shift; + + return 'Moose::Util::does_role(' + . $val . ', ' + . B::perlstring($self->role) + . ')'; +}; + sub new { my ( $class, %args ) = @_; $args{parent} = Moose::Util::TypeConstraints::find_type_constraint('Object'); - my $self = $class->_new(\%args); + + my $role_name = $args{role}; + $args{constraint} = sub { Moose::Util::does_role( $_[0], $role_name ) }; + + $args{inlined} = $inliner; + + my $self = $class->_new( \%args ); $self->_create_hand_optimized_type_constraint; $self->compile_type_constraint(); @@ -102,14 +115,12 @@ sub create_child_type { 1; +# ABSTRACT: Role/TypeConstraint parallel hierarchy + __END__ =pod -=head1 NAME - -Moose::Meta::TypeConstraint::Role - Role/TypeConstraint parallel hierarchy - =head1 DESCRIPTION This class represents type constraints for a role. @@ -165,21 +176,6 @@ object! =head1 BUGS -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. - -=head1 AUTHOR - -Yuval Kogman Enothingmuch@cpan.orgE - -=head1 COPYRIGHT AND LICENSE - -Copyright 2006-2009 by Infinity Interactive, Inc. - -L - -This library is free software; you can redistribute it and/or modify -it under the same terms as Perl itself. +See L for details on reporting bugs. =cut