DBIx::Class::Schema::Critic and parameterized roles
I originally started DBIx::Class::Schema::Critic as a code sample for a job application, but I thought it was worth releasing and continued independent development. Inspired by Perl::Critic, it's a package for comparing relational database schemas against a collection of best practice policies using the DBIx::Class Object/Relational Mapper.
At mst's behest I converted it from the Moose object system to his more lightweight Moo. But now that I've accumulated a few policy modules I'd like to refactor their commonalities out into roles.
Trouble is that Moo doesn't have an equivalent to Moose's MooseX::Role::Parameterized, and I can definitely see use for that in creating a bunch of similar roles for each DBIx::Class object a policy applies to.
So what to do? Can/should I port parameterized roles to Moo, while avoiding the overhead of a meta-object protocol like Moose's Class::MOP (which Moo explicitly rejects)? Or just make a bunch of more-or-less identical roles that differ only in name and attribute content, accepting the repetition as the price of minimalism?
Please please please do not write a MooX::Role::Parameterized. If you need parameterized roles, use Moose.
Thanks, I posted this just to get that kind of feedback.
Very clever! Coincidentally, I'm starting a fresh project with DBIx::Class, so I can't wait to try the Schema::Critic.
I've been thinking about porting Perl::Critic to Moose (or Moo or Mouse), so I'm very curious to look at your implementation.
-Jeff
I just released version 0.013, which uses a parent role to collect all the names of the applied child roles and glom them into an array reference attribute. Seems to work for what I need, which is a way for a policy to state what it processes without necessarily tying it to anything fancier than a method call. (Some people may not like Mo(o|use|ose).)
It was originally done with Moose, so you could conceivably go back before version 0.010 to find more Moose-ish ways to do things.
Also note that it doesn't require your database have a DBIx::Class layer -- it will create one on the fly using DBIx::Class::Schema::Loader if needed.
There are a lot more things that I'd like to borrow from P::C, like severity levels and configurability. P::C also has PBP as a starting point -- is there something similar for relational databases that I could use to generate policies?