removed parenthesis hackage and updated docs
[gitmo/MooseX-Types.git] / t / lib / DecoratorLibrary.pm
CommitLineData
20b6a7d1 1package DecoratorLibrary;
2
20b6a7d1 3use MooseX::Types::Moose qw( Str ArrayRef HashRef Int );
4use MooseX::Types
5 -declare => [qw(
6 MyArrayRefBase
7 MyArrayRefInt01
8 MyArrayRefInt02
a706b0f2 9 MyHashRefOfInts
10 MyHashRefOfStr
cf1a8bfa 11 StrOrArrayRef
e088dd03 12 AtLeastOneInt
20b6a7d1 13 )];
14
475bbd1d 15## Some questionable messing around
16 sub my_subtype {
17 my ($subtype, $basetype, @rest) = @_;
18 return subtype($subtype, $basetype, shift @rest, shift @rest);
19 }
20
21 sub my_from {
22 return @_;
23
24 }
25 sub my_as {
26 return @_;
27 }
28## End
29
20b6a7d1 30subtype MyArrayRefBase,
31 as ArrayRef;
32
33coerce MyArrayRefBase,
34 from Str,
35 via {[split(',', $_)]};
36
37subtype MyArrayRefInt01,
38 as ArrayRef[Int];
39
40coerce MyArrayRefInt01,
41 from Str,
42 via {[split('\.',$_)]},
43 from HashRef,
54f5d4e6 44 via {[sort values(%$_)]};
20b6a7d1 45
46subtype MyArrayRefInt02,
47 as MyArrayRefBase[Int];
a706b0f2 48
49subtype MyHashRefOfInts,
50 as HashRef[Int];
51
52subtype MyHashRefOfStr,
53 as HashRef[Str];
20b6a7d1 54
55coerce MyArrayRefInt02,
56 from Str,
a706b0f2 57 via {[split(':',$_)]},
58 from MyHashRefOfInts,
59 via {[sort values(%$_)]},
60 from MyHashRefOfStr,
61 via {[ sort map { length $_ } values(%$_) ]},
d9002a85 62 from HashRef[ArrayRef],
e088dd03 63 via {[ sort map { @$_ } values(%$_) ]};
cf1a8bfa 64
65subtype StrOrArrayRef,
e088dd03 66 as Str|ArrayRef;
475bbd1d 67
e088dd03 68subtype AtLeastOneInt,
d9002a85 69 as ArrayRef[Int],
e088dd03 70 where { @$_ > 0 };
475bbd1d 71
20b6a7d1 721;