in reply to Moose goodness for status-code values?

I do think that Traits are likely to be the solution, and I was hoping that one already existed ... especially since I see a “MooseX::TypeMap” that looks very interesting indeed but that is not quite what I want.

The motivation for my quest is that these status-codes are already present in a large database and already being used in the crufty code that my team is re-engineering.   There is, therefore, a lot of code that tests these values with eq, and we have already encountered several places in which that isolated logic is outright wrong.

So, obviously, I want to consolidate into one Moose-goodness place:  

And of course, “laziness is a virtue.”

What do I want?

has 'status' => ( traits => ['plugh'], # IF THIS IS NEEDED FOR THE MAGICK ... may_be_undef => 0, values => { 'status_alive' => 'A', ' status_dead' => 'D', }, handles => { # OR MAYBE SOME OTHER SUGAR-WORD ... 'is_alive' => 'status_alive', 'is_dead' => 'status_dead', }, );

And my obvious thought is ... hasn’t this already been done by somebody else?   The assumption that surely somebody has, and that I just haven’t discovered it yet, is rather compelling.