2 package DecoratorLibrary;
4 use MooseX::Types::Moose qw( Str ArrayRef HashRef Int );
19 subtype MyArrayRefBase,
22 coerce MyArrayRefBase,
24 via {[split(',', $_)]};
26 subtype MyArrayRefInt01,
33 ## We can change this when the .61 Moose comes out. When that happens we will
34 ## have the correct patch to Moose::Meta::TypeConstraint::Parameterized to let
35 ## us support parameterizing parameterized subtypes. When we get this we can
36 ## then replace the where clause with:
38 ##as MyArrayRefInt01[BiggerInt];
40 subtype SubOfMyArrayRefInt01,
44 foreach my $int (@$_) {
45 $ok_or_not = $int>10 ? 1:0
50 coerce MyArrayRefInt01,
52 via {[split('\.',$_)]},
54 via {[sort values(%$_)]};
56 subtype MyArrayRefInt02,
57 as MyArrayRefBase[Int];
59 subtype MyHashRefOfInts,
62 subtype MyHashRefOfStr,
65 coerce MyArrayRefInt02,
67 via {[split(':',$_)]},
69 via {[sort values(%$_)]},
71 via {[ sort map { length $_ } values(%$_) ]},
72 from HashRef[ArrayRef],
73 via {[ sort map { @$_ } values(%$_) ]};
75 subtype StrOrArrayRef,
78 subtype AtLeastOneInt,
83 (qw/Programming Teaching Banking/);
87 package DecoratorLibrary;
89 use MooseX::Types::Moose qw( Str ArrayRef HashRef Int );
104 subtype MyArrayRefBase,
107 coerce MyArrayRefBase,
109 via {[split(',', $_)]};
111 subtype MyArrayRefInt01,
118 subtype SubOfMyArrayRefInt01,
119 as MyArrayRefInt01[BiggerInt];
121 coerce MyArrayRefInt01,
123 via {[split('\.',$_)]},
125 via {[sort values(%$_)]};
127 subtype MyArrayRefInt02,
128 as MyArrayRefBase[Int];
130 subtype MyHashRefOfInts,
133 subtype MyHashRefOfStr,
136 coerce MyArrayRefInt02,
138 via {[split(':',$_)]},
139 from MyHashRefOfInts,
140 via {[sort values(%$_)]},
142 via {[ sort map { length $_ } values(%$_) ]},
143 from HashRef[ArrayRef],
144 via {[ sort map { @$_ } values(%$_) ]};
146 subtype StrOrArrayRef,
149 subtype AtLeastOneInt,
154 (qw/Programming Teaching Banking/);
157 >>>>>>> .merge-right.r6407