File: Moose.pm

package info (click to toggle)
libmoosex-types-perl 0.22-1
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 312 kB
  • ctags: 168
  • sloc: perl: 2,440; makefile: 2
file content (84 lines) | stat: -rw-r--r-- 1,522 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
package MooseX::Types::Moose;
our $VERSION = "0.22";

=head1 NAME

MooseX::Types::Moose - Types shipped with L<Moose>

=cut

use warnings;
use strict;

use MooseX::Types;
use Moose::Util::TypeConstraints ();

use namespace::clean -except => [qw( meta )];

=head1 SYNOPSIS

  package Foo;
  use Moose;
  use MooseX::Types::Moose qw( Int Str );
  use Carp qw( croak );

  has 'name',
    is  => 'rw',
    isa => Str;

  has 'id',
    is  => 'rw',
    isa => Int;

  sub add {
      my ($self, $x, $y) = @_;
      croak 'First arg not an Int'  unless is_Int($x);
      croak 'Second arg not an Int' unless is_Int($y);
      return $x + $y;
  }

  1;

=head1 DESCRIPTION

This package contains a virtual library for L<MooseX::Types> that
is able to export all types known to L<Moose>. See L<MooseX::Types>
for general usage information.

=cut

# all available builtin types as short and long name
my %BuiltIn_Storage 
  = map { ($_) x 2 } 
    Moose::Util::TypeConstraints->list_all_builtin_type_constraints;

=head1 METHODS

=head2 type_storage

Overrides L<MooseX::Types::Base>' C<type_storage> to provide a hash
reference containing all built-in L<Moose> types.

=cut

# use prepopulated builtin hash as type storage
sub type_storage { \%BuiltIn_Storage }

=head1 SEE ALSO

L<MooseX::Types::Moose>,
L<Moose>, 
L<Moose::Util::TypeConstraints>

=head1 AUTHOR

See L<MooseX::Types/AUTHOR>.

=head1 LICENSE

This program is free software; you can redistribute it and/or modify
it under the same terms as perl itself.

=cut

1;