Chris,

> Just to throw a third approach in...

The more the merrier. :-)

> Given that this is easily achievable with builders/defaults (if you're
> willing to set them on every attribute), I'd probably just wrap the
> Moose::Meta::Attribute::_process_options() method (via an attribute trait)
> along the lines of:

Well, I like this for its simplicity.  I think part of my original
problem was being hung up on the idea that I needed a builder when
really a default works just as well (probably better); both
ealleniii's and your solutions showed me the folly of my ways.

> This is minimally invasive, and leverages pre-existing bits to achieve its
> ends.  ...assuming that I've understood what you were aiming for.

No, you've hit it straight on the head, and I agree it's minimally
invasive, but the downside is that I'd be wrapping a private method,
which strikes me as dangerous.  What if that chunk of Moose guts
changes out from under me?

> ...do note that you'll need to pay attention to the attribute-from-role and
> extends cases; such an exercise is left for the reader.  (Though the code in
> MooseX::AttributeShortcuts should help.)

Hmmm ... yes, I'd have to worry about that if I decided to make this
general enough to release to CPAN, but for my initial purposes it
probably wouldn't matter.

BTW, in the odd coincidence department, your AutoDestruct attribute
trait was one of the ones I was cribbing off of when I wrote my
original attempt (the other being Karen Etheridge's
SlurpyConstructor).  So thanks for that inadvertent bit of inspiration
as well. :-)


            -- Buddy

Reply via email to