I have the following code duplicated several times as I have several classes that follow the same pattern
use MooseX::Types -declare [ qw( Item ) ];jj
my $itc = $prefix . 'Item';
class_type Item, { class => $itc };
coerce Item, from HashRef, via { load_class( $itc )->new( $_ ) };
is there an easy way for me to deduplicate the code that creates the class_type
and coercion? This is not a problem understanding MooseX::Types but a problem of a large amount of duplicated code. Here is a link to that code in its current state. It's turned into a bit of a mess, and isn't something I'm proud of.