2 package MooseX::Getopt::OptionTypeMap;
5 use Moose::Util::TypeConstraints 'find_type_constraint';
8 our $AUTHORITY = 'cpan:STEVAN';
10 my %option_type_map = (
20 my (undef, $type_name) = @_;
21 return 1 if exists $option_type_map{$type_name};
23 my $current = find_type_constraint($type_name);
24 while (my $parent = $current->parent) {
25 return 1 if exists $option_type_map{$parent->name};
33 my (undef, $type_name) = @_;
34 return $option_type_map{$type_name}
35 if exists $option_type_map{$type_name};
37 my $current = find_type_constraint($type_name);
38 while (my $parent = $current->parent) {
39 return $option_type_map{$parent->name}
40 if exists $option_type_map{$parent->name};
47 sub add_option_type_to_map {
48 my (undef, $type_name, $option_string) = @_;
49 (defined $type_name && defined $option_string)
50 || confess "You must supply both a type name and an option string";
51 (find_type_constraint($type_name))
52 || confess "The type constraint '$type_name' does not exist";
53 $option_type_map{$type_name} = $option_string;
56 no Moose; no Moose::Util::TypeConstraints; 1;
65 MooseX::Getopt::OptionTypeMap - Storage for the option to type mappings
69 See the I<Custom Type Constraints> section in the L<MooseX::Getopt> docs
70 for more info about how to use this module.
74 These are all class methods and should be called as such.
78 =item B<has_option_type ($type_name)>
80 =item B<get_option_type ($type_name)>
82 =item B<add_option_type_to_map ($type_name, $option_spec)>
88 All complex software has bugs lurking in it, and this module is no
89 exception. If you find a bug please either email me, or add the bug
94 Stevan Little E<lt>stevan@iinteractive.comE<gt>
96 =head1 COPYRIGHT AND LICENSE
98 Copyright 2007 by Infinity Interactive, Inc.
100 L<http://www.iinteractive.com>
102 This library is free software; you can redistribute it and/or modify
103 it under the same terms as Perl itself.