Commit | Line | Data |
4c2125a4 |
1 | package MooseX::Types::TypeDecorator; |
2 | |
3 | use Moose; |
4 | use Moose::Util::TypeConstraints; |
5 | use Moose::Meta::TypeConstraint (); |
6 | |
7 | use overload( |
8 | '""' => sub { |
9 | shift->type_constraint->name; |
10 | }, |
11 | ); |
12 | |
13 | =head1 NAME |
14 | |
15 | MooseX::Types::TypeDecorator - More flexible access to a Type Constraint |
16 | |
17 | =head1 DESCRIPTION |
18 | |
19 | This is a decorator object that contains an underlying type constraint. We use |
20 | this to control access to the type constraint and to add some features. |
21 | |
22 | =head1 TYPES |
23 | |
24 | The following types are defined in this class. |
25 | |
26 | =head2 Moose::Meta::TypeConstraint |
27 | |
28 | Used to make sure we can properly validate incoming type constraints. |
29 | |
30 | =cut |
31 | |
32 | class_type 'Moose::Meta::TypeConstraint'; |
33 | |
34 | =head2 MooseX::Types::UndefinedType |
35 | |
36 | Used since sometimes our constraint is an unknown type. |
37 | |
38 | =cut |
39 | |
40 | class_type 'MooseX::Types::UndefinedType'; |
41 | |
42 | =head1 ATTRIBUTES |
43 | |
44 | This class defines the following attributes |
45 | |
46 | =head2 type_constraint |
47 | |
48 | This is the type constraint that we are delegating |
49 | |
50 | =cut |
51 | |
52 | has 'type_constraint' => ( |
53 | is=>'ro', |
54 | isa=>'Moose::Meta::TypeConstraint|MooseX::Types::UndefinedType', |
55 | handles=>[ |
56 | Moose::Meta::TypeConstraint->meta->compute_all_applicable_methods, |
57 | "_compiled_type_constraint", |
58 | ], |
59 | ); |
60 | |
61 | =head1 METHODS |
62 | |
63 | This class defines the following methods. |
64 | |
65 | =head1 AUTHOR AND COPYRIGHT |
66 | |
67 | John Napiorkowski (jnapiorkowski) <jjnapiork@cpan.org> |
68 | |
69 | =head1 LICENSE |
70 | |
71 | This program is free software; you can redistribute it and/or modify |
72 | it under the same terms as perl itself. |
73 | |
74 | =cut |
75 | |
76 | 1; |