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