Commit | Line | Data |
3fea05b9 |
1 | use strict; |
2 | use warnings; |
3 | |
4 | package Parse::Method::Signatures::Types; |
5 | |
6 | use Moose::Util::TypeConstraints; |
7 | use MooseX::Types::Moose qw/Str ArrayRef/; |
8 | use namespace::clean; |
9 | |
10 | use MooseX::Types -declare => [qw/ |
11 | VariableName |
12 | TypeConstraint |
13 | Param |
14 | ParamCollection |
15 | PositionalParam |
16 | NamedParam |
17 | UnpackedParam |
18 | /]; |
19 | |
20 | subtype VariableName, |
21 | as Str, |
22 | where { /^[\$@%](?:[a-z_][a-z_\d]*)?$/i }, |
23 | message { 'not a valid variable name' }; |
24 | |
25 | subtype TypeConstraint, |
26 | as 'Moose::Meta::TypeConstraint'; |
27 | |
28 | class_type Param, { class => 'Parse::Method::Signatures::Param' }; |
29 | |
30 | class_type ParamCollection, { class => 'Parse::Method::Signatures::ParamCollection' }; |
31 | |
32 | coerce ParamCollection, |
33 | from ArrayRef, |
34 | via { Parse::Method::Signatures::ParamCollection->new(params => $_) }; |
35 | |
36 | role_type PositionalParam, { role => 'Parse::Method::Signatures::Param::Positional' }; |
37 | role_type NamedParam, { role => 'Parse::Method::Signatures::Param::Named' }; |
38 | role_type UnpackedParam, { role => 'Parse::Method::Signatures::Param::Unpacked' }; |
39 | |
40 | 1; |