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.

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.


Leave a comment

About Mark Gardner

user-pic I'm a developer currently working as a build automation engineer for an e-commerce services company. I've been working with Perl since 1994, and although I started focused on web applications I've gradually moved into toolsmithing and custom applications. My PAUSE/CPAN ID is MJGARDNER, and I usually host my public development efforts on GitHub.