Tuesday July 15, 2008
Thoughts on parametrized roles for Moose
Moose might allow roles a little bit more freedom on how the are used by allowing parameters to be passed to roles. So the role can use those during initialization to act accordingly.
This will allow to e.g. set a method prefix for a role's methods, or set some defaults, initialize some other stuff...
Here's how it could look like:
with role 'My::Role'; ### no magic here same as: with 'My::Role';
with role 'MooseX::Log::Log4perl' => ':easy'; ### pass a param
with role 'MooseX::Log::Log4perl', prefix => 'mylog_'; ### pass the param hash/pair to a role
For more on that read this post...