The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Jojo::Role - Role::Tiny + lexical "with"

VERSION

version 0.3.1

SYNOPSIS

  package Some::Role {
    use Jojo::Role;    # requires perl 5.18+

    sub foo {...}
    sub bar {...}
    around baz => sub {...};
  }

  package Some::Class {
    use Jojo::Role -with;
    with 'Some::Role';

    # bar gets imported, but not foo
    sub foo {...}

    # baz is wrapped in the around modifier by Class::Method::Modifiers
    sub baz {...}
  }

DESCRIPTION

Jojo::Role works like Role::Tiny but with, require, before, after and around are imported as lexical subroutines.

This is a companion to Jojo::Base.

CAVEATS

  • Jojo::Role requires perl 5.18 or newer

  • Because a lexical sub does not behave like a package import, some code may need to be enclosed in blocks to avoid warnings like

        "state" subroutine &has masks earlier declaration in same scope at...

SEE ALSO

Role::Tiny, Mojo::Bass.

AUTHOR

Adriano Ferreira <ferreira@cpan.org>

CONTRIBUTOR

Adriano Ferreira <a.r.ferreira@gmail.com>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Adriano Ferreira.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.