in reply to Re: Remove a role from a Moose object
in thread Remove a role from a Moose object

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
  • Comment on Re^2: Remove a role from a Moose object

Replies are listed 'Best First'.
Re^3: Remove a role from a Moose object
by Corion (Patriarch) on Nov 07, 2016 at 08:46 UTC

    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
Re^3: Remove a role from a Moose object
by RonW (Parson) on Nov 11, 2016 at 18:36 UTC
    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.