Re: Can't specify trait option when a role consumer modifies an attribute?

2009-08-20 Thread Hans Dieter Pearcey
Excerpts from Elliot Shank's message of Wed Aug 19 21:26:43 -0700 2009:
> If you uncomment the one line in the code below, you get a "Illegal inherited
> options => (getopt_name)" error.  Is there any way around this?
>
> has '+modified_attribute' => (
> traits  => [ qw< MooseX::Getopt::Defanged::Option > ],
> #getopt_name => 'modified',
> );

I think this means it's time to kill the "list of valid inherited options" and
replace it with a "list of invalid inherited options".  Any volunteers?

hdp.


Re: Can't specify trait option when a role consumer modifies an attribute?

2009-08-19 Thread Jesse Luehrs
On Thu, Aug 20, 2009 at 12:53:17AM -0400, Chris Prather wrote:
> On Thu, Aug 20, 2009 at 12:26 AM, Elliot Shank wrote:
> > If you uncomment the one line in the code below, you get a "Illegal
> > inherited options => (getopt_name)" error.  Is there any way around this?
> 
> Yes, but it isn't pretty. Moose::Meta::Attribute defines a set of
> "legal_options_for_inheritance", and getopt_name isn't one of them
> (obviously since Moose doesn't even know about it). You need to
> override the legal_options_for_inheritance method from
> Moose::Meta::Attribute and add that method to the allowed methods ...
> or complain to #moose-dev about why we have a hard coded list with no
> easy way to override it ...  complaining with a topic/ branch to show
> how easy a solution would be to implement and some docs and tests will
> probably work best and earn you a frosty beverage of your choice.
> 
> -Chris
> 
> It's late and I can't really come up with a better solution right now,
> perhaps someone who's less tired will have one?

Well, obviously, if it's meant to work with overriding, then mx-getopt or
whatever should be overriding legal_options_for_inheritance in the
metaclass. Getting rid of legal_options_for_inheritance altogether would
be an alternative solution too though(:

-doy


Re: Can't specify trait option when a role consumer modifies an attribute?

2009-08-19 Thread Chris Prather
On Thu, Aug 20, 2009 at 12:26 AM, Elliot Shank wrote:
> If you uncomment the one line in the code below, you get a "Illegal
> inherited options => (getopt_name)" error.  Is there any way around this?

Yes, but it isn't pretty. Moose::Meta::Attribute defines a set of
"legal_options_for_inheritance", and getopt_name isn't one of them
(obviously since Moose doesn't even know about it). You need to
override the legal_options_for_inheritance method from
Moose::Meta::Attribute and add that method to the allowed methods ...
or complain to #moose-dev about why we have a hard coded list with no
easy way to override it ...  complaining with a topic/ branch to show
how easy a solution would be to implement and some docs and tests will
probably work best and earn you a frosty beverage of your choice.

-Chris

It's late and I can't really come up with a better solution right now,
perhaps someone who's less tired will have one?