in reply to Re^4: Remove roles for an object in perl moose
in thread Remove roles for an object in perl moose

You want to model vehicles that can convert themselves into other vehicles? Like the batmobile?

Because if not, then you're going about this the wrong way. You shouldn't be converting cars into bikes and vice versa. You should just have car objects and bike objects.

Further, if seems you have Vehicle as a class and Car and Bike as roles. That should be the other way around; Vehicle should be a role that Car and Bike both do.

use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name
  • Comment on Re^5: Remove roles for an object in perl moose

Replies are listed 'Best First'.
Re^6: Remove roles for an object in perl moose
by rbala (Acolyte) on Oct 01, 2013 at 09:12 UTC
    Hi , Somehow, it is like batmobiles only. In the delegation apporach you suggested, is it possible in any way to add all the methods of the class teacher entirely instead of adding all api's. Instead , can we add the entire class to the handles, so that all the methods within the class is accesbile through the classroom object apart from 'teach' method. Thanks, Bala.

      OK, here's my take on how the Batmobile could be modelled with roles. It would be cute if it weren't also scary crazy.

      use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

      Hmmm... the Batmobile is an interesting object to model. I'll have a think about it.

      use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name