Re: Extending an attribute with a trait

[email protected] (Stevan Little)
Newsgroups perl.moose
Message-ID <[email protected]>
Dan,

Roles don't inherit, so you want 'around' instead of 'override'  
sorry, my fault i used a term that is also a keyword :)

- Stevan

On Jul 16, 2008, at 11:16 AM, Dan Harbin wrote:

> Stevan,
>
> I changed the code as follows, and it still fails.  This trait
> doesn't/can't inherit from Moose::Meta::Attribute, so I think the
> override method is a no-op.  How do I fix this?
>
> Dan
>
> -----------------
>
> package Demo::Meta::Attribute::Trait::Foo;
> use Moose::Role;
>
> has foo => (
>     is => 'rw',
>     isa => 'Str',
>     required => 1,
> );
>
> override 'legal_options_for_inheritance' => sub {
>   my @options = super();
>   push @options, 'foo';
>   return @options;
> };
>
> package Moose::Meta::Attribute::Custom::Trait::Foo;
> sub register_implementation { 'Demo::Meta::Attribute::Trait::Foo' }
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.