Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
laziness, impatience, and hubris
 
PerlMonks  

Re^2: Can't locate object method- Issue

by perl_noobie (Initiate)
on Aug 03, 2013 at 11:52 UTC ( #1047699=note: print w/ replies, xml ) Need Help??


in reply to Re: Can't locate object method- Issue
in thread Can't locate object method- Issue

Thanks for the implementation idea. Though the sample script that you have given works well if maintained in a single file, I tried splitting each package in a new file and this does not work as expected. Can someone help resolve this?


Comment on Re^2: Can't locate object method- Issue
Re^3: Can't locate object method- Issue
by tobyink (Abbot) on Aug 03, 2013 at 11:56 UTC

    See my recent update.

    package Cow { use Moo; has name => (is => 'lazy', default => sub { 'Mooington' }) } say Cow->new->name
      Is there any way that a role can be removed after being assigned to a object? In my case, I would like to have a role assigned to an object, but during the course of the script, my roles for the particular object need to be modified. I want to remove the earlier role and add a new role to the object. Is there a way to do this?

        This sounds like horribly bad design.

        You haven't told us what problem you are trying to solve by this approach, but from my perspective, it looks as if your approach would be far better served by an object A that has another object B, which gets removed or replaced by a third object C if its behavirour needs to change:

        A -> B # Change behaviour: A -> C

        Maybe, B and C can implement some roles, but the interface of A should remain identical and delegate to its worker, B or C.

      Is there any way that a role can be removed after being assigned to a object? In my case, I would like to have a role assigned to an object, but during the course of the script, my roles for the particular object need to be modified. I want to remove the earlier role and add a new role to the object. Is there a way to do this?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1047699]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (6)
As of 2014-04-20 16:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (485 votes), past polls