Mojo::RoleTiny - Tiny and simple role system for Mojo
# role class package MojoCoreMantainer; use Mojo::RoleTiny; sub mantaining_mojo { say "I'm making improvements for Mojolicious..." } # base class package Developer; use Mojo::Base -base; sub make_code { say "I'm making code for Mojolicious ecosystem..." } # class package People; use Mojo::Base 'Developer'; # using roles use Mojo::RoleTiny -with; with 'MojoCoreMantainer'; # method sub what_can_i_do { my $self = shift; say "I can do people things..."; $self->make_code; $self->mantaining_mojo; }
Explanation
This module init named as Mojo::Role but was changed at the request of sri because an official Mojolicious role implementation is in development.
This module provide a simple and light dependence way to use roles in Mojolicious classes.
# For a role class use Mojo::RoleTiny; # To use/consume a role use Mojo::RoleTiny -with; with 'Role::SomeRoleClass';
Mojo::RoleTiny optionally exports a with function, that can be imported with the -with flag. When exported the caller is not implementing a role but rather consuming them.
with
-with
with 'SomeRoleClass';
Import a role or a list of roles to use.
Daniel Vinciguerra <daniel.vinciguerra at bivee.com.br>
Joel Berger (jberger)
Matt S. Trout (mst)
Copyright (C) 2016, Daniel Vinciguerra and "CONTRIBUTORS".
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
https://github.com/kraih/mojo, Mojo::Base, Role::Tiny, http://mojolicious.org.
To install Mojo::RoleTiny, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojo::RoleTiny
CPAN shell
perl -MCPAN -e shell install Mojo::RoleTiny
For more information on module installation, please visit the detailed CPAN module installation guide.