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