X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMooseX%2FGetopt%2FOptionTypeMap.pm;h=3d94c785e7b27785ce9ac49ccc73d7cd3cdb39ee;hb=edfb736cb47388616f04aef731cb0cd047bcaa91;hp=10de77f105857c8679d90d66ddd2db5052ccded6;hpb=1566a17bad230f7f8560beb67acbbf55a99cde58;p=gitmo%2FMooseX-Getopt.git diff --git a/lib/MooseX/Getopt/OptionTypeMap.pm b/lib/MooseX/Getopt/OptionTypeMap.pm index 10de77f..3d94c78 100644 --- a/lib/MooseX/Getopt/OptionTypeMap.pm +++ b/lib/MooseX/Getopt/OptionTypeMap.pm @@ -4,7 +4,7 @@ package MooseX::Getopt::OptionTypeMap; use Moose 'confess'; use Moose::Util::TypeConstraints 'find_type_constraint'; -our $VERSION = '0.02'; +our $VERSION = '0.03'; our $AUTHORITY = 'cpan:STEVAN'; my %option_type_map = ( @@ -21,6 +21,10 @@ sub has_option_type { return 1 if exists $option_type_map{$type_name}; my $current = find_type_constraint($type_name); + + (defined $current) + || confess "Could not find the type constraint for '$type_name'"; + while (my $parent = $current->parent) { return 1 if exists $option_type_map{$parent->name}; $current = $parent; @@ -31,10 +35,15 @@ sub has_option_type { sub get_option_type { my (undef, $type_name) = @_; + return $option_type_map{$type_name} if exists $option_type_map{$type_name}; my $current = find_type_constraint($type_name); + + (defined $current) + || confess "Could not find the type constraint for '$type_name'"; + while (my $parent = $current->parent) { return $option_type_map{$parent->name} if exists $option_type_map{$parent->name}; @@ -81,6 +90,8 @@ These are all class methods and should be called as such. =item B +=item B + =back =head1 BUGS