3 MooseX::Types::CheckedUtilExports - Wrap L<Moose::Util::TypeConstraints> to be
4 safer for L<MooseX::Types>
8 package MooseX::Types::CheckedUtilExports;
13 use Moose::Util::TypeConstraints ();
18 use namespace::clean -except => 'meta';
21 q{WARNING: String found where Type expected (did you use a => instead of a , ?)};
23 my @exports = qw/type subtype maybe_type duck_type enum coerce from as/;
32 Which should be written as:
37 When using L<MooseX::Types>. Exported by that module.
39 Exports checked versions of the following subs:
41 C<type> C<subtype> C<maybe_type> C<duck_type> C<enum> C<coerce> C<from> C<as>
43 While C<class_type> and C<role_type> will also register the type in the library.
45 From L<Moose::Util::TypeConstraints>. See that module for syntax.
49 for my $export (@exports) {
55 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
59 $_[0] =~ /\b::\b/ || # qualified type
60 $caller->get_registered_class_type($_[0]) ||
61 $caller->get_registered_role_type($_[0]);
63 goto &{"Moose::Util::TypeConstraints::$export"};
67 Moose::Exporter->setup_import_methods(
68 with_caller => [ @exports, 'class_type', 'role_type' ]
74 $caller->register_class_type(
75 Moose::Util::TypeConstraints::class_type(@_)
80 my ($caller, $name, $opts) = @_;
82 $caller->register_role_type(
83 Moose::Util::TypeConstraints::role_type($name, $opts)
93 See L<MooseX::Types/AUTHOR>.
97 This program is free software; you can redistribute it and/or modify
98 it under the same terms as perl itself.