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