Finishing off 0.01
[gitmo/MooseX-Types.git] / lib / MooseX / Types / Moose.pm
1 package MooseX::Types::Moose;
2
3 =head1 NAME
4
5 MooseX::Types::Moose - Types shipped with L<Moose>
6
7 =cut
8
9 use warnings;
10 use strict;
11
12 use MooseX::Types;
13 use Moose::Util::TypeConstraints ();
14
15 use namespace::clean -except => [qw( meta )];
16
17 =head1 SYNOPSIS
18
19   package Foo;
20   use Moose;
21   use MooseX::Types::Moose qw( Int Str );
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
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>
45 for general usage information.
46
47 =cut
48
49 # all available builtin types as short and long name
50 my %BuiltIn_Storage 
51   = map { ($_) x 2 } 
52     Moose::Util::TypeConstraints->list_all_builtin_type_constraints;
53
54 =head1 METHODS
55
56 =head2 type_storage
57
58 Overrides L<MooseX::Types::Base>' C<type_storage> to provide a hash
59 reference containing all built-in L<Moose> types.
60
61 =cut
62
63 # use prepopulated builtin hash as type storage
64 sub type_storage { \%BuiltIn_Storage }
65
66 =head1 SEE ALSO
67
68 L<MooseX::Types::Moose>,
69 L<Moose>, 
70 L<Moose::Util::TypeConstraints>
71
72 =head1 AUTHOR AND COPYRIGHT
73
74 Robert 'phaylon' Sedlacek C<E<lt>rs@474.atE<gt>>, with many thanks to
75 the C<#moose> cabal on C<irc.perl.org>.
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
84 1;