Evo::Class::Role
version 0.0213
Role is just like classes except you can only reuse it. You can't create an instance of the role. If you need to reuse a code without "should be overriden by subclass" hacks - role is just what you expecting
Also can be used as "interaces"
package main; use Evo; { # role package My::Role; use Evo '-Class::Role *; -Loaded'; has myattr => 'VAL'; sub to_lc($self) : Public { lc $self->myattr } # class package My::Class; use Evo '-Class *'; with 'My::Role'; } my $obj = My::Class->new(); say $obj->to_lc; # value { # just check implementation package My::BadClass; use Evo '-Class *'; # will die implements 'My::Role'; }
alexbyk.com
This software is copyright (c) 2016 by alexbyk.
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 Evo, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Evo
CPAN shell
perl -MCPAN -e shell install Evo
For more information on module installation, please visit the detailed CPAN module installation guide.