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

Re: MooX::HandlesVia problem

Thread Previous | Thread Next
From:
Stephen Quinney
Date:
August 19, 2015 16:57
Subject:
Re: MooX::HandlesVia problem
Message ID:
CAJ+y7SxGCdzkA_EoS7mD0BG=6sV=2CzxNiBOqHexpi4Xs6Xn6g@mail.gmail.com
To partially answer my own question, it appears that if I use "with" once
for each role it works fine, for example:

{
    package SJQ::Baz;
    use Moo;

    with 'SJQ::Role::Foo';
    with 'SJQ::Role::Bar';

    use namespace::clean;
}

I'm still not clear on why that is necessary though.




On 19 August 2015 at 16:03, Stephen Quinney <stephen@jadevine.org.uk> 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();
>
>
>
>

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