1 package MooseX::Types::CheckedUtilExports;
3 #ABSTRACT: Wrap L<Moose::Util::TypeConstraints> to be safer for L<MooseX::Types>
7 use Moose::Util::TypeConstraints ();
12 use namespace::autoclean;
15 q{WARNING: String found where Type expected (did you use a => instead of a , ?)};
17 my @exports = qw/type subtype maybe_type duck_type enum coerce from as/;
26 Which should be written as:
31 When using L<MooseX::Types>. Exported by that module.
33 Exports checked versions of the following subs:
35 C<type> C<subtype> C<maybe_type> C<duck_type> C<enum> C<coerce> C<from> C<as>
37 While C<class_type> and C<role_type> will also register the type in the library.
39 From L<Moose::Util::TypeConstraints>. See that module for syntax.
43 for my $export (@exports) {
49 local $Carp::CarpLevel = $Carp::CarpLevel + 1;
53 $_[0] =~ /\b::\b/ || # qualified type
54 $caller->get_registered_class_type($_[0]) ||
55 $caller->get_registered_role_type($_[0]);
57 goto &{"Moose::Util::TypeConstraints::$export"};
61 Moose::Exporter->setup_import_methods(
62 with_caller => [ @exports, 'class_type', 'role_type' ]
68 $caller->register_class_type(
69 Moose::Util::TypeConstraints::class_type(@_)
74 my ($caller, $name, $opts) = @_;
76 $caller->register_role_type(
77 Moose::Util::TypeConstraints::role_type($name, $opts)
87 This program is free software; you can redistribute it and/or modify
88 it under the same terms as perl itself.