File: Types.pm

package info (click to toggle)
libparse-method-signatures-perl 1.003019-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye, buster
  • size: 280 kB
  • sloc: perl: 3,081; makefile: 2
file content (40 lines) | stat: -rw-r--r-- 1,059 bytes parent folder | download | duplicates (6)
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
use strict;
use warnings;

package Parse::Method::Signatures::Types;

use Moose::Util::TypeConstraints;
use MooseX::Types::Moose qw/Str ArrayRef/;
use namespace::clean;

use MooseX::Types -declare => [qw/
    VariableName
    TypeConstraint
    Param
    ParamCollection
    PositionalParam
    NamedParam
    UnpackedParam
/];

subtype VariableName,
    as Str,
    where { /^[\$@%](?:[a-z_][a-z_\d]*)?$/i },
    message { 'not a valid variable name' };

subtype TypeConstraint,
    as 'Moose::Meta::TypeConstraint';

class_type Param, { class => 'Parse::Method::Signatures::Param' };

class_type ParamCollection, { class => 'Parse::Method::Signatures::ParamCollection' };

coerce ParamCollection,
    from ArrayRef,
    via { Parse::Method::Signatures::ParamCollection->new(params => $_) };

role_type PositionalParam, { role => 'Parse::Method::Signatures::Param::Positional' };
role_type NamedParam,      { role => 'Parse::Method::Signatures::Param::Named'      };
role_type UnpackedParam,   { role => 'Parse::Method::Signatures::Param::Unpacked'   };

1;