Re: Trying to create an attribute trait that prompts for a value if none specified
[email protected] (Buddy Burden)
| Newsgroups | perl.moose |
|---|---|
| Message-ID | <CAL0mxoQ0G84+4WL_fP+1Hi2VFkNekjS2sR00hM88rjxWRvw01w@mail.gmail.com> |
Chris,
> I've always had the opinion that if I'm writing metaclass traits, then by
> definition I'm changing the private parts to accomplish my task. Which to
> me makes it far more acceptable than, say, poking at _process_options() from
> outside of Moose::Meta::Attribute. That is, I'm not accessing private
> methods inappropriately, as once the trait is consumed it's part of the
> class itself. (/me braces for contrary commentary)
Well, that's a fair point. My only counterpoint would be this bit of code:
> $class->_process_options($name, \%options) unless $options{__hack_no_process_options}; # used from clone()... YECHKKK FIXME ICKY YUCK GROSS
which leads me to believe that, eventually, someone is going to change
*something* about it. :-D
> Well, that and I'm not sure how to accomplish any of this _without_ poking
> at the guts :)
Well, both ealleniii and Todd provided alternatives which don't rely
on any private methods, but yours has the advantage of being the
absolute simplest (and least scary, really, private-method-meddling
and all). So I think I'm going to go with this approach for now. If
any other Moosites want to chiime in and tell me it's a terrible
thing, I'll consider that if I do end up getting that wild hair and
trying to wrestle it into a CPAN release. But for now this works
really well and doesn't hurt my brain too much. :-)
-- Buddy