Skip to content

Instantly share code, notes, and snippets.

@jjn1056
Created April 2, 2020 02:44
Show Gist options
  • Save jjn1056/5543c977a2829f624947b93fd2628892 to your computer and use it in GitHub Desktop.
Save jjn1056/5543c977a2829f624947b93fd2628892 to your computer and use it in GitHub Desktop.
package MooX::TrackRoles;
use Role::Tiny ();
sub import {
my $class = shift;
my $target = caller;
die "'$target' is not a Role" unless Role::Tiny->is_role($target);
eval qq[
package ${target};
sub does_roles { shift->maybe::next::method(\@_) }
];
my $around = \&{"${target}::around"};
$around->(does_roles => sub {
my ($orig, $self) = @_;
return ($self->$orig, $target);
});
}
1;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment