Guys,

Okay, basically what I want is just what the subject says: you might
declare your attribute something like so:

    has value => ( traits => [qw< Promptable >], is => 'rw', isa =>
'Int', prompt => 'Please enter a value:' );

then, for each instance, if you provide a value in new(), that's the
value; if you don't, it prompts the user for it.  The basic idea is I
can use this with MooseX::App::Cmd for switches that are not provided
on the command-line.

So, my first approach was to around attach_to_class and just stick a
builder method in.  But you can't actually _set_ a builder, because
builder is essentially a read-only attribute of the attribute
metaclass.

Okay, no problem: I'll just intercept BUILDARGS for the attribute
metaclass and slip a builder in there as if the client had specified
it.  No go:

> The method 'BUILDARGS' was not found in the inheritance hierarchy for 
> Moose::Meta::Class::__ANON__::SERIAL::15 at 
> /usr/local/lib64/perl5/Class/MOP/Class.pm line 1048

I guess roles can't mess with the BUILDARGS for the classes they're
composed into ... ?  I could imagine that being a reasonable
restriction.

Okay, next try:  I'll around initialize_slot_instance for the
attribute metaclass and prompt right there, and slip the user-supplied
value into $params before passing it onto $orig (only if not already
there and after validation, natch).  But my around method for
initialize_slot_instance is never called, it seems ... not sure why
... because it's being supplied by a role? because the new() is being
inlined? other?

So now I'm out of ideas.  Can anyone tell me what's wrong with any of
the approaches, or if there's a whole 'nother approach that I should
be using? or maybe there's some helpful module I've missed in my CPAN
searches?  Anything?  I'd really appreciate it.

Thanx for all you do, Moosites.  Moose makes my job easier every day.
Keep up the good work.


            -- Buddy

Reply via email to