Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re: Remove a role from a Moose object

by kevbot (Vicar)
on Nov 07, 2016 at 04:47 UTC ( [id://1175411]=note: print w/replies, xml ) Need Help??


in reply to Remove a role from a Moose object

The Remove roles for an object in perl moose node and this thread on the perl.moose mailing list have related discussions.

Replies are listed 'Best First'.
Re^2: Remove a role from a Moose object
by balachandran (Novice) on Nov 07, 2016 at 06:20 UTC
    Thanks for the pointers. The "Remove roles for an object in perl moose" thread discusses the scenario where the roles have been applied to an instance rather than the class. But in my case, it is applied to the class and only in certain scenarios (less frequent) we need it removed from the instance. Thanks

      Maybe think of all classes as unconfigurable and only enable it for those cases where it needs to be configurable?

      I would look at this as having two classes and transferring the data from the ::Configurable class into the ::Unconfigurable class. The ::Unconfigurable class could be the naked Host package, and the Host::Configurable class could be Host with Configurable.

        Thanks, I can try this approach. It needs a bit of changes to other related code. So, I'll go with this if I am not able to figure out other ways of achieving this. Thanks
      thread discusses the scenario where the roles have been applied to an instance rather than the class. But in my case, it is applied to the class and only in certain scenarios (less frequent) we need it removed from the instance.

      Maybe the constructor for your class could apply the role to new instances, then you could remove the role, as needed, from individual instances.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2024-03-28 14:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found