NAME

Evo::Class::Role

VERSION

version 0.0213

DESCRIPTION

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"

SYNOPSYS

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';
}

AUTHOR

alexbyk.com

COPYRIGHT AND LICENSE

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.