I see a few potential problems with the strategy you describe here, perhaps they are related to why the Boolean module doesn't work the way you'd like out of the box. You might want to take another look though, it does help get you most of the way there.

One problem is that you didn't follow the convention of storing a single bit of information using 0 for false/fail and 1 for true/pass. The easiest solution here is to go with the flow and use something like $record->status(0) for fail, and $record->status(1) for pass. Next easiest would be to define functions called pass and fail, so you can use them as barewords instead of 0 and 1.

Or, you can have the user pass specific values such as 'F' or 'P', and still /store/ the value as a native boolean. You would have to write your own accessor, but it wouldn't be terribly complex, and what you are requesting is pretty unusual / dangerous style-wise, I'm not surprised there isn't yet a module to automagically create method names for each potential value of a variable in the namespace of it's containing class.

Having said that, when you know you want to create them, you could just declare the accessor subs yourself along with the attribute in a Moose::Role, and then 'with' them into whatever class(es) you'd like, which is a little bit automagical.


In reply to Re^2: Moose goodness for status-code values? by dynamo
in thread Moose goodness for status-code values? by locked_user sundialsvc4

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.