develooper Front page | perl.moose | Postings from January 2010

Re: MooseX::Role::Strict + MooseX::Role::Parameterized

Thread Previous | Thread Next
Shawn M Moore
January 5, 2010 10:33
Re: MooseX::Role::Strict + MooseX::Role::Parameterized
Message ID:
Hash: SHA1

On 1/4/10 10:38 PM, Karen Etheridge wrote:
> What would it take to gain the properties of MooseX::Role::Strict in
> MooseX::Role::Parameterized?  I've been using strict roles everywhere and
> love them -- they've caught a few bugs that I'm sure would have been
> dreadful to track down otherwise; now I'm parameterizing a few of my roles
> and I'm mourning the loss of strict checking.

MooseX::Role::Parameterized is designed to be as extensible as Moose, so
I would hope that it can support this.

When you say "package Foo; use MooseX::Role::Parameterized;" it creates
a role metaobject for Foo, the class of which is
MooseX::Role::Parameterized::Meta::Role::Parameterizable (quite a
mouthful). In MXRPMRP there is a constant:

use constant parameterized_role_metaclass =>

This constant decides the class of the role metaobject created when you
apply the parameterized role. So, to get what you want, I think you need to:

1. define a class (for now let's call it Role::Strict::Parameterized)
   1a. subclass MooseX::Role::Parameterized::Meta::Role::Parameterized
   1b. also subclass MooseX::Meta::Role::Strict
2. subclass MooseX::Role::Parameterized::Meta::Role::Parameterizable
   2a. use constant parameterized_role_metaclass =>

You'll have multiple inheritance, which obviously sucks. I'm sorry for
my half of that. It will be straightforward for me to refactor the guts
of MooseX::Role::Parameterized::Meta::Role::Parameterizable (which is
just two attributes) into a role. I'll do that at some point this week.

Hopefully that makes some amount of sense. You have a lot of
metaprogramming ahead of you. Good luck and feel free to ask plenty more

Version: GnuPG v1.4.10 (Darwin)


Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About