develooper Front page | perl.moose | Postings from August 2015

Re: MooX::HandlesVia problem

Thread Previous | Thread Next
From:
Graham Knop
Date:
August 21, 2015 15:01
Subject:
Re: MooX::HandlesVia problem
Message ID:
20150821150043.665.qmail@lists-nntp.develooper.com
On 8/19/15 11:03 AM, Stephen Quinney wrote:
> I have a problem with using MooX::HandlesVia for attributes in roles
> when I consume more than one role in a class. I get:
> 
> "Due to a method name conflict between roles 'SJQ::Role::Bar and
> SJQ::Role::Foo', the method 'has' must be implemented by 'SJQ::Baz' at
> /usr/share/perl5/vendor_perl/Role/Tiny.pm line 215."
> 
> I can't see what I'm doing wrong here, any suggestions?
> 
> Here's an example:
> 
> {
>     package SJQ::Role::Foo;
>     use Moo::Role;
>     use MooX::HandlesVia;
> }
> 
> {
>     package SJQ::Role::Bar;
>     use Moo::Role;
>     use MooX::HandlesVia;
> }
> 
> {
>     package SJQ::Baz;
>     use Moo;
> 
>     with 'SJQ::Role::Foo','SJQ::Role::Bar';
> 
>     use namespace::clean;
> }
> 
> my $test = SJQ::Baz->new();
> 
> 
> 

This is a known issue: https://github.com/mattp-/MooX-HandlesVia/issues/4

Using namespace::clean is what I would recommend for a workaround.  A
proper fix will involve an additional routine in Moo that
MooX::HandlesVia can use.  This has been on my todo list for a while but
hasn't yet made it to the top.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About