1 package DecoratorLibrary;
6 use MooseX::Types::Moose qw( Str ArrayRef HashRef Int );
18 subtype MyArrayRefBase,
21 coerce MyArrayRefBase,
23 via {[split(',', $_)]};
25 subtype MyArrayRefInt01,
28 coerce MyArrayRefInt01,
30 via {[split('\.',$_)]},
32 via {[sort values(%$_)]};
34 subtype MyArrayRefInt02,
35 as MyArrayRefBase[Int];
37 subtype MyHashRefOfInts,
40 subtype MyHashRefOfStr,
43 coerce MyArrayRefInt02,
45 via {[split(':',$_)]},
47 via {[sort values(%$_)]},
49 via {[ sort map { length $_ } values(%$_) ]},
50 ## Can't do HashRef[ArrayRef] here since if I do HashRef get the via {}
51 ## Stuff passed as args.
52 from HashRef([ArrayRef]),
53 via {[ sort map { @$_ } values(%$_) ]};
55 subtype StrOrArrayRef,
58 subtype AtLeastOneInt,
59 ## Same problem as MyArrayRefInt02, see above. Another way to solve it by
60 ## forcing some sort of context. Tried to fix this with method prototypes
61 ## but just couldn't make it work.