MooseX::Role::Callback
package Foo; use Moose::Role; use MooseX::Role::Callback; included(sub { my ($meta, $user) = @_; print "Foo applied to " . $user->name . "\n"; }); package Bar; use Moose; with 'Foo'; # Prints "Foo applied to Bar"
Execute a callback function when a role is applied.
included
Registers a function to be called when the role is applied. Takes a single coderef as an argument.
The function will be passed the role's metaclass and the $thing's metaclass, where $thing can be either class or instance.
$thing
Call multiple times to register multiple callbacks.
Find this project on github:
https://github.com/pboyd/MooseX-Role-Callback
Paul Boyd <pboyd@cpan.org>
This software is copyright (c) 2012 by Paul Boyd.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install MooseX::Role::Callback, copy and paste the appropriate command in to your terminal.
cpanm
cpanm MooseX::Role::Callback
CPAN shell
perl -MCPAN -e shell install MooseX::Role::Callback
For more information on module installation, please visit the detailed CPAN module installation guide.