On Thu, Dec 22, 2011 at 1:40 PM, Buddy Burden <[email protected]>wrote:
> I'm still experimenting here, but I had a couple of questions
Just to throw a third approach in...
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:
before _process_options => sub {
my ($class, $name, $options) = @_;
# if any of these are set, then... wtf?
return if $options->{builder} || $options->{default} || defined
$options->{required};
$options->{required} = 1;
$options->{default} = sub { ... magic prompting code ... };
return;
};
This is minimally invasive, and leverages pre-existing bits to achieve its
ends. ...assuming that I've understood what you were aiming for. Adding a
custom prompt option should be pretty straight-forward from this point, and
building a Moose::Exporter package to apply it should be so as well.
...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.)
-Chris
--
Chris Weyl
Ex astris scientia