Re: Using attributes for 'requires'

[email protected] (Darren Duncan)
Newsgroups perl.moose
Message-ID <[email protected]>
benh wrote:
> so far the best hack is :
> 
> sub location;
> has location => (...);

Following this suggestion, I tried it myself (Moose 0.64, Class::MOP 0.75) to 
solve a related problem, where the auto-generated methods meant to satisfy a 
role's requirements are delegates to an attribute of the composing class:

     has '_inner' => (
         is      => 'rw',
         isa     => 'MyInnerClass',
         handles => [qw(
             foo_func bar_func
         )],
     );

However, adding ...

     sub foo_func;
     sub bar_func;

... above the has _inner didn't work; I got this compile time error:

     Error:  You cannot overwrite a locally defined method (foo_func) with a 
delegation

So, any similar hacks to help with that, prior to Moose roles being smart enough 
to deal with this?

-- Darren Duncan
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.