X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FTypeConstraint%2FEnum.pm;h=65e6c868d62a7237dac52c57ba4f19d36cda013d;hb=d03bd989b97597428b460d7f9a021e2931893fa0;hp=023e8b112c2df324b72ac85663e69347aeae76e0;hpb=f4cbcca146f48c91c74ae618f71895376fd338a4;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/TypeConstraint/Enum.pm b/lib/Moose/Meta/TypeConstraint/Enum.pm index 023e8b1..65e6c86 100644 --- a/lib/Moose/Meta/TypeConstraint/Enum.pm +++ b/lib/Moose/Meta/TypeConstraint/Enum.pm @@ -6,7 +6,7 @@ use metaclass; use Moose::Util::TypeConstraints (); -our $VERSION = '0.55_03'; +our $VERSION = '0.75_01'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -67,6 +67,11 @@ sub _compile_hand_optimized_type_constraint { sub { defined($_[0]) && !ref($_[0]) && exists $values{$_[0]} }; } +sub create_child_type { + my ($self, @args) = @_; + return Moose::Meta::TypeConstraint->new(@args, parent => $self); +} + 1; __END__ @@ -77,25 +82,51 @@ __END__ Moose::Meta::TypeConstraint::Enum - Type constraint for enumerated values. +=head1 DESCRIPTION + +This class represents type constraints based on an enumerated list of +acceptable values. + +=head1 INHERITANCE + +C is a subclass of +L. + =head1 METHODS =over 4 -=item B +=item B<< Moose::Meta::TypeConstraint::Enum->new(%options) >> + +This creates a new class type constraint based on the given +C<%options>. + +It takes the same options as its parent, with several +exceptions. First, it requires an additional option, C. This +should be an array reference containing a list of valid string +values. Second, it automatically sets the parent to the C type. + +Finally, it ignores any provided C option. The constraint +is generated automatically based on the provided C + +=item B<< $constraint->values >> -=item B +Returns the array reference of acceptable values provided to the +constructor. -=item B +=item B<< $constraint->create_child_type >> -=item B +This returns a new L object with the type +as its parent. -=item B +Note that it does I return a C +object! =back =head1 BUGS -All complex software has bugs lurking in it, and this module is no +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. @@ -105,7 +136,7 @@ Yuval Kogman Enothingmuch@cpan.orgE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2008 by Infinity Interactive, Inc. +Copyright 2006-2009 by Infinity Interactive, Inc. L