v_melnik has asked for the wisdom of the Perl Monks concerning the following question:
Dear colleagues,
I started using Moose about a month ago and I like it.
Now I have a situation when I have some role (let's call it Role) consumed by two classes - ClassA and ClassB. The role has a method called do_something(). This method being called as ClassA->do_something() creates a ClassB-object.
require ClassB.pm; $objB = ClassB->new();
As I see by further tests, it works fine, but I'm getting warnings:
Subroutine foo redefined at /XXX/lib/YYY/ClassB.pm line 17. Subroutine bar redefined at /XXX/lib/YYY/ClassB.pm line 23. Subroutine baz redefined at /XXX/lib/YYY/ClassB.pm line 30.
Actually it says all methods I have in the role are redefined.
Is there a way to create a ClassB object from ClassA if both classes consume the same role?
Lots of thanks for your help!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Two Moose classes consumering the same role and using each other
by jeffa (Bishop) on Jun 26, 2014 at 16:39 UTC | |
|
Re: Two Moose classes consumering the same role and using each other
by Anonymous Monk on Jun 26, 2014 at 11:59 UTC | |
by v_melnik (Scribe) on Jun 26, 2014 at 12:42 UTC | |
by tobyink (Canon) on Jun 26, 2014 at 22:34 UTC | |
by v_melnik (Scribe) on Jun 27, 2014 at 08:50 UTC |