Blame README

Packit 73b376
NAME
Packit 73b376
    Role::Tiny - Roles. Like a nouvelle cuisine portion size slice of Moose.
Packit 73b376
Packit 73b376
SYNOPSIS
Packit 73b376
     package Some::Role;
Packit 73b376
Packit 73b376
     use Role::Tiny;
Packit 73b376
Packit 73b376
     sub foo { ... }
Packit 73b376
Packit 73b376
     sub bar { ... }
Packit 73b376
Packit 73b376
     around baz => sub { ... };
Packit 73b376
Packit 73b376
     1;
Packit 73b376
Packit 73b376
    elsewhere
Packit 73b376
Packit 73b376
     package Some::Class;
Packit 73b376
Packit 73b376
     use Role::Tiny::With;
Packit 73b376
Packit 73b376
     # bar gets imported, but not foo
Packit 73b376
     with 'Some::Role';
Packit 73b376
Packit 73b376
     sub foo { ... }
Packit 73b376
Packit 73b376
     # baz is wrapped in the around modifier by Class::Method::Modifiers
Packit 73b376
     sub baz { ... }
Packit 73b376
Packit 73b376
     1;
Packit 73b376
Packit 73b376
    If you wanted attributes as well, look at Moo::Role.
Packit 73b376
Packit 73b376
DESCRIPTION
Packit 73b376
    "Role::Tiny" is a minimalist role composition tool.
Packit 73b376
Packit 73b376
ROLE COMPOSITION
Packit 73b376
    Role composition can be thought of as much more clever and meaningful
Packit 73b376
    multiple inheritance. The basics of this implementation of roles is:
Packit 73b376
Packit 73b376
    * If a method is already defined on a class, that method will not be
Packit 73b376
      composed in from the role. A method inherited by a class gets
Packit 73b376
      overridden by the role's method of the same name, though.
Packit 73b376
Packit 73b376
    * If a method that the role "requires" to be implemented is not
Packit 73b376
      implemented, role application will fail loudly.
Packit 73b376
Packit 73b376
    Unlike Class::C3, where the last class inherited from "wins," role
Packit 73b376
    composition is the other way around, where the class wins. If multiple
Packit 73b376
    roles are applied in a single call (single with statement), then if any
Packit 73b376
    of their provided methods clash, an exception is raised unless the class
Packit 73b376
    provides a method since this conflict indicates a potential problem.
Packit 73b376
Packit 73b376
IMPORTED SUBROUTINES
Packit 73b376
  requires
Packit 73b376
     requires qw(foo bar);
Packit 73b376
Packit 73b376
    Declares a list of methods that must be defined to compose role.
Packit 73b376
Packit 73b376
  with
Packit 73b376
     with 'Some::Role1';
Packit 73b376
Packit 73b376
     with 'Some::Role1', 'Some::Role2';
Packit 73b376
Packit 73b376
    Composes another role into the current role (or class via
Packit 73b376
    Role::Tiny::With).
Packit 73b376
Packit 73b376
    If you have conflicts and want to resolve them in favour of Some::Role1
Packit 73b376
    you can instead write:
Packit 73b376
Packit 73b376
     with 'Some::Role1';
Packit 73b376
     with 'Some::Role2';
Packit 73b376
Packit 73b376
    If you have conflicts and want to resolve different conflicts in favour
Packit 73b376
    of different roles, please refactor your codebase.
Packit 73b376
Packit 73b376
  before
Packit 73b376
     before foo => sub { ... };
Packit 73b376
Packit 73b376
    See "before method(s) => sub { ... }" in Class::Method::Modifiers for
Packit 73b376
    full documentation.
Packit 73b376
Packit 73b376
    Note that since you are not required to use method modifiers,
Packit 73b376
    Class::Method::Modifiers is lazily loaded and we do not declare it as a
Packit 73b376
    dependency. If your Role::Tiny role uses modifiers you must depend on
Packit 73b376
    both Class::Method::Modifiers and Role::Tiny.
Packit 73b376
Packit 73b376
  around
Packit 73b376
     around foo => sub { ... };
Packit 73b376
Packit 73b376
    See "around method(s) => sub { ... }" in Class::Method::Modifiers for
Packit 73b376
    full documentation.
Packit 73b376
Packit 73b376
    Note that since you are not required to use method modifiers,
Packit 73b376
    Class::Method::Modifiers is lazily loaded and we do not declare it as a
Packit 73b376
    dependency. If your Role::Tiny role uses modifiers you must depend on
Packit 73b376
    both Class::Method::Modifiers and Role::Tiny.
Packit 73b376
Packit 73b376
  after
Packit 73b376
     after foo => sub { ... };
Packit 73b376
Packit 73b376
    See "after method(s) => sub { ... }" in Class::Method::Modifiers for
Packit 73b376
    full documentation.
Packit 73b376
Packit 73b376
    Note that since you are not required to use method modifiers,
Packit 73b376
    Class::Method::Modifiers is lazily loaded and we do not declare it as a
Packit 73b376
    dependency. If your Role::Tiny role uses modifiers you must depend on
Packit 73b376
    both Class::Method::Modifiers and Role::Tiny.
Packit 73b376
Packit 73b376
  Strict and Warnings
Packit 73b376
    In addition to importing subroutines, using "Role::Tiny" applies strict
Packit 73b376
    and warnings to the caller.
Packit 73b376
Packit 73b376
SUBROUTINES
Packit 73b376
  does_role
Packit 73b376
     if (Role::Tiny::does_role($foo, 'Some::Role')) {
Packit 73b376
       ...
Packit 73b376
     }
Packit 73b376
Packit 73b376
    Returns true if class has been composed with role.
Packit 73b376
Packit 73b376
    This subroutine is also installed as ->does on any class a Role::Tiny is
Packit 73b376
    composed into unless that class already has an ->does method, so
Packit 73b376
Packit 73b376
      if ($foo->does('Some::Role')) {
Packit 73b376
        ...
Packit 73b376
      }
Packit 73b376
Packit 73b376
    will work for classes but to test a role, one must use ::does_role
Packit 73b376
    directly.
Packit 73b376
Packit 73b376
    Additionally, Role::Tiny will override the standard Perl "DOES" method
Packit 73b376
    for your class. However, if "any" class in your class' inheritance
Packit 73b376
    hierarchy provides "DOES", then Role::Tiny will not override it.
Packit 73b376
Packit 73b376
METHODS
Packit 73b376
  apply_roles_to_package
Packit 73b376
     Role::Tiny->apply_roles_to_package(
Packit 73b376
       'Some::Package', 'Some::Role', 'Some::Other::Role'
Packit 73b376
     );
Packit 73b376
Packit 73b376
    Composes role with package. See also Role::Tiny::With.
Packit 73b376
Packit 73b376
  apply_roles_to_object
Packit 73b376
     Role::Tiny->apply_roles_to_object($foo, qw(Some::Role1 Some::Role2));
Packit 73b376
Packit 73b376
    Composes roles in order into object directly. Object is reblessed into
Packit 73b376
    the resulting class. Note that the object's methods get overridden by
Packit 73b376
    the role's ones with the same names.
Packit 73b376
Packit 73b376
  create_class_with_roles
Packit 73b376
     Role::Tiny->create_class_with_roles('Some::Base', qw(Some::Role1 Some::Role2));
Packit 73b376
Packit 73b376
    Creates a new class based on base, with the roles composed into it in
Packit 73b376
    order. New class is returned.
Packit 73b376
Packit 73b376
  is_role
Packit 73b376
     Role::Tiny->is_role('Some::Role1')
Packit 73b376
Packit 73b376
    Returns true if the given package is a role.
Packit 73b376
Packit 73b376
CAVEATS
Packit 73b376
    *   On perl 5.8.8 and earlier, applying a role to an object won't apply
Packit 73b376
        any overloads from the role to other copies of the object.
Packit 73b376
Packit 73b376
    *   On perl 5.16 and earlier, applying a role to a class won't apply any
Packit 73b376
        overloads from the role to any existing instances of the class.
Packit 73b376
Packit 73b376
SEE ALSO
Packit 73b376
    Role::Tiny is the attribute-less subset of Moo::Role; Moo::Role is a
Packit 73b376
    meta-protocol-less subset of the king of role systems, Moose::Role.
Packit 73b376
Packit 73b376
    Ovid's Role::Basic provides roles with a similar scope, but without
Packit 73b376
    method modifiers, and having some extra usage restrictions.
Packit 73b376
Packit 73b376
AUTHOR
Packit 73b376
    mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
Packit 73b376
Packit 73b376
CONTRIBUTORS
Packit 73b376
    dg - David Leadbeater (cpan:DGL) <dgl@dgl.cx>
Packit 73b376
Packit 73b376
    frew - Arthur Axel "fREW" Schmidt (cpan:FREW) <frioux@gmail.com>
Packit 73b376
Packit 73b376
    hobbs - Andrew Rodland (cpan:ARODLAND) <arodland@cpan.org>
Packit 73b376
Packit 73b376
    jnap - John Napiorkowski (cpan:JJNAPIORK) <jjn1056@yahoo.com>
Packit 73b376
Packit 73b376
    ribasushi - Peter Rabbitson (cpan:RIBASUSHI) <ribasushi@cpan.org>
Packit 73b376
Packit 73b376
    chip - Chip Salzenberg (cpan:CHIPS) <chip@pobox.com>
Packit 73b376
Packit 73b376
    ajgb - Alex J. G. Burzyński (cpan:AJGB) <ajgb@cpan.org>
Packit 73b376
Packit 73b376
    doy - Jesse Luehrs (cpan:DOY) <doy at tozt dot net>
Packit 73b376
Packit 73b376
    perigrin - Chris Prather (cpan:PERIGRIN) <chris@prather.org>
Packit 73b376
Packit 73b376
    Mithaldu - Christian Walde (cpan:MITHALDU)
Packit 73b376
    <walde.christian@googlemail.com>
Packit 73b376
Packit 73b376
    ilmari - Dagfinn Ilmari Mannsåker (cpan:ILMARI) <ilmari@ilmari.org>
Packit 73b376
Packit 73b376
    tobyink - Toby Inkster (cpan:TOBYINK) <tobyink@cpan.org>
Packit 73b376
Packit 73b376
    haarg - Graham Knop (cpan:HAARG) <haarg@haarg.org>
Packit 73b376
Packit 73b376
COPYRIGHT
Packit 73b376
    Copyright (c) 2010-2012 the Role::Tiny "AUTHOR" and "CONTRIBUTORS" as
Packit 73b376
    listed above.
Packit 73b376
Packit 73b376
LICENSE
Packit 73b376
    This library is free software and may be distributed under the same
Packit 73b376
    terms as perl itself.
Packit 73b376