Commit | Line | Data |
---|---|---|
52d358e2 | 1 | package MooseX::Types::Moose; |
e211870f | 2 | |
e981324f | 3 | # ABSTRACT: Type exports that match the types shipped with L<Moose> |
e211870f | 4 | |
8af0a70d | 5 | use warnings; |
6 | use strict; | |
7 | ||
52d358e2 | 8 | use MooseX::Types; |
8af0a70d | 9 | use Moose::Util::TypeConstraints (); |
9616cebc | 10 | |
4eb26e95 | 11 | use namespace::autoclean; |
8af0a70d | 12 | |
e211870f | 13 | =head1 SYNOPSIS |
14 | ||
15 | package Foo; | |
16 | use Moose; | |
c4997e0c | 17 | use MooseX::Types::Moose qw( ArrayRef Int Str ); |
e211870f | 18 | use Carp qw( croak ); |
19 | ||
20 | has 'name', | |
21 | is => 'rw', | |
22 | isa => Str; | |
23 | ||
c4997e0c | 24 | has 'ids', |
e211870f | 25 | is => 'rw', |
c4997e0c | 26 | isa => ArrayRef[Int]; |
e211870f | 27 | |
28 | sub add { | |
29 | my ($self, $x, $y) = @_; | |
30 | croak 'First arg not an Int' unless is_Int($x); | |
31 | croak 'Second arg not an Int' unless is_Int($y); | |
32 | return $x + $y; | |
33 | } | |
34 | ||
35 | 1; | |
36 | ||
37 | =head1 DESCRIPTION | |
38 | ||
52d358e2 | 39 | This package contains a virtual library for L<MooseX::Types> that |
40 | is able to export all types known to L<Moose>. See L<MooseX::Types> | |
e211870f | 41 | for general usage information. |
42 | ||
43 | =cut | |
44 | ||
8af0a70d | 45 | # all available builtin types as short and long name |
e9dc30af | 46 | my %BuiltIn_Storage |
47 | = map { ($_) x 2 } | |
e9c7cea8 | 48 | Moose::Util::TypeConstraints->list_all_builtin_type_constraints; |
8af0a70d | 49 | |
e211870f | 50 | =head1 METHODS |
51 | ||
52 | =head2 type_storage | |
53 | ||
52d358e2 | 54 | Overrides L<MooseX::Types::Base>' C<type_storage> to provide a hash |
e211870f | 55 | reference containing all built-in L<Moose> types. |
56 | ||
57 | =cut | |
58 | ||
8af0a70d | 59 | # use prepopulated builtin hash as type storage |
60 | sub type_storage { \%BuiltIn_Storage } | |
61 | ||
e211870f | 62 | =head1 SEE ALSO |
63 | ||
52d358e2 | 64 | L<MooseX::Types::Moose>, |
e9dc30af | 65 | L<Moose>, |
e211870f | 66 | L<Moose::Util::TypeConstraints> |
67 | ||
e211870f | 68 | =head1 LICENSE |
69 | ||
70 | This program is free software; you can redistribute it and/or modify | |
71 | it under the same terms as perl itself. | |
72 | ||
73 | =cut | |
74 | ||
8af0a70d | 75 | 1; |