189f274b415ba1c1052292794037775f2c04ec5d
[gitmo/MooseX-Types.git] / lib / MooseX / Types / Moose.pm
1 package MooseX::Types::Moose;
2
3 # ABSTRACT: Type exports that match the types shipped with L<Moose>
4
5 use warnings;
6 use strict;
7
8 use MooseX::Types;
9 use Moose::Util::TypeConstraints ();
10
11 use namespace::clean -except => [qw( meta )];
12
13 =head1 SYNOPSIS
14
15   package Foo;
16   use Moose;
17   use MooseX::Types::Moose qw( Int Str );
18   use Carp qw( croak );
19
20   has 'name',
21     is  => 'rw',
22     isa => Str;
23
24   has 'id',
25     is  => 'rw',
26     isa => Int;
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
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>
41 for general usage information.
42
43 =cut
44
45 # all available builtin types as short and long name
46 my %BuiltIn_Storage 
47   = map { ($_) x 2 } 
48     Moose::Util::TypeConstraints->list_all_builtin_type_constraints;
49
50 =head1 METHODS
51
52 =head2 type_storage
53
54 Overrides L<MooseX::Types::Base>' C<type_storage> to provide a hash
55 reference containing all built-in L<Moose> types.
56
57 =cut
58
59 # use prepopulated builtin hash as type storage
60 sub type_storage { \%BuiltIn_Storage }
61
62 =head1 SEE ALSO
63
64 L<MooseX::Types::Moose>,
65 L<Moose>, 
66 L<Moose::Util::TypeConstraints>
67
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
75 1;