How do you do per-object role composition on the typical OO/role frameworks e.g. Moose or Moo (I'm using Role::Tiny in this particular case)? So basically I create a role for a class, and I want the user to be able to mix that class on an as-needed basis. The manual way would be for the user to create a subclass:
package MyClass_With_Role1;
use parent 'MyClass';
use Role::Tiny::With;
with 'Role1';
Is there a shortcut for it? Something like:
my $obj = MyClass->new_with_roles('Role1');
I suspect Moose et al supports something like this, but I've never done this and do not know where to look.