I'm attempting to allow an attribute trait's attributes (meta meta meta) to be overridden via the 
"has '+foo' ..." form, but this doesn't seem to work.  It doesn't look like my 
"around" of Moose::Meta::Attribute::legal_options_for_inheritance() is being invoked.

What am I doing wrong?  I'm guessing that it has something to do with the role 
attribute not having the trait, but, of course, that's one of the things I'm 
trying to do here.


=== error ===

Illegal inherited options => (getopt_name) at 
/Users/elliot/opt/perl/perl-5.10.0-64bit-threads/lib/site_perl/5.10.0/Moose/Meta/Class.pm
 line 565
        
Moose::Meta::Class::_process_inherited_attribute('Moose::Meta::Class=HASH(0x9e7488)',
 'modified_attribute', 'definition_context', 'HASH(0xbb4470)', 'getopt_name', 
'modified', 'traits', 'ARRAY(0x9e9dd4)') called at 
/Users/elliot/opt/perl/perl-5.10.0-64bit-threads/lib/site_perl/5.10.0/Moose/Meta/Class.pm
 line 547
        
Moose::Meta::Class::_process_attribute('Moose::Meta::Class=HASH(0x9e7488)', 
'+modified_attribute', 'definition_context', 'HASH(0xbb4470)', 'getopt_name', 
'modified', 'traits', 'ARRAY(0x9e9dd4)') called at 
/Users/elliot/opt/perl/perl-5.10.0-64bit-threads/lib/site_perl/5.10.0/Moose/Meta/Class.pm
 line 246
        Moose::Meta::Class::add_attribute('Moose::Meta::Class=HASH(0x9e7488)', 
'+modified_attribute', 'definition_context', 'HASH(0xbb4470)', 'getopt_name', 
'modified', 'traits', 'ARRAY(0x9e9dd4)') called at 
/Users/elliot/opt/perl/perl-5.10.0-64bit-threads/lib/site_perl/5.10.0/Moose.pm 
line 69
        Moose::has('Moose::Meta::Class=HASH(0x9e7488)', '+modified_attribute', 
'traits', 'ARRAY(0x9e9dd4)', 'getopt_name', 'modified') called at 
/Users/elliot/opt/perl/perl-5.10.0-64bit-threads/lib/site_perl/5.10.0/Moose/Exporter.pm
 line 288
        Moose::has('+modified_attribute', 'traits', 'ARRAY(0x9e9dd4)', 
'getopt_name', 'modified') called at test line 45


=== file "test" ===

package MooseX::Getopt::Defanged::Meta::Attribute::Trait::_Getopt;

use 5.010;
use Moose::Role;

has getopt_name => (
   isa         => 'Str',
   is          => 'ro',
   required    => 0,
   reader      => 'get_getopt_name',
   writer      => 'set_getopt_name',
);

my @extra_legal_options = qw< getopt_name >;
around legal_options_for_inheritance => sub {
   my ($original, $self, @arguments) = @_;

   return $self->$original(@arguments), @extra_legal_options;
}; # end around legal_options_for_inheritance()


package Moose::Meta::Attribute::Custom::Trait::MooseX::Getopt::Defanged::Option;

sub register_implementation {
   return 'MooseX::Getopt::Defanged::Meta::Attribute::Trait::_Getopt';
} # end register_implementation()


package Role;

use Moose::Role;

has modified_attribute => (
   is      => 'rw',
   isa     => 'Str',
);


package Consumer;

use Moose;

with qw< Role MooseX::Getopt::Defanged >;

has '+modified_attribute' => (
   traits      => [ qw< MooseX::Getopt::Defanged::Option > ],
   getopt_name => 'modified',
);

Reply via email to