My Moose object has an attribute that is an arrayref of strings. I want to make it possible to set it to a single-element list by passing only a single string ('string'), instead of an arrayref of a single string (['string']).
has 'my_list' => (
is => 'rw',
isa => 'ArrayRef[Str]',
);
What is the proper way of solving this? Through a trigger?
I'm not sure yet if I'll need this in both the object constructor and the attribute setter, or only in the constructor.
The best way to approach this is by using type coercion (creating one type from another).
Note, that it's a bad idea to coerce into standard Moose types, so we also create a subtype.