Kavorka::Manual::MethodModifiers(3pm)

NAME
Kavorka::Manual::MethodModifiers - before/after/around keywords

DESCRIPTION
Kavorka provides the "before", "after" and "around" keywords for method modifiers.

Method modifiers should work in Moose, Moo, Mouse and Role::Tiny classes and roles. In other classes they will fall back to using Class::Method::Modifiers.

The keywords "augment" and "override" are also available, but will only work in classes backed by a framework that supports these modifiers (i.e. Moose or Mouse, but not Moo).

The anatomy of a method modifier:

1.  The keyword introducing the method.

2.  The method names.

3.  The signature (optional).

4.  Traits (optional).

5.  The prototype (optional).

6.  The attribute list (optional).

7.  The modifier body.

Example:

   #  (1)   (2)    (3)    (4)     (5)  (6)     (7)
      after foobar ($foo) is cool :($) :cached { $self->log("foobar $foo") }

  The Keyword
By default, these keywords are exported. They must be exported by request:

   use Kavorka qw( before after around );
   use Kavorka qw( -modifiers );

  The Method Names
These are the names of the methods being wrapped.

Multiple names may be separated by colons:

   after foo, bar, baz { ... }

  The Signature
See Kavorka::Manual::Signatures.

The "before" and "after" keywords have a default invocant called $self, but it does not have a type constraint, so can equally be used for class or object methods.

The "around" modifier defines two invocants called $next and $self. ("${^NEXT}" is also available as an alias for $next for backwards compatibility with Moops::MethodModifiers.)

Beware using type constraints for method modifiers (which are essentially wrappers); constraints will be checked at each level of wrapping which will slow down method calls.

  Traits
See Kavorka::Manual::ExtendingKavorka.

  The Prototype
See Kavorka::Manual::PrototypeAndAttributes.

Note however that prototypes are fairly useless for methods.

  The Attributes
Attributes may alternatively be provided before the signature.

See Kavorka::Manual::PrototypeAndAttributes.

Note that this applies the attribute to the modifier code, and not to the method being modified.

  The Modifier Body
This is more or less what you'd expect from the modifier body you'd write with Moose, however the lexical variables for parameters are pre-declared and pre-populated, and invocants have been shifted off @_.

BUGS
Please report any bugs to <http://rt.cpan.org/Dist/Display.html?Queue=Kavorka>.

SEE ALSO
Kavorka::Manual, Kavorka::Manual::Signatures, Kavorka::Manual::PrototypeAndAttributes, Kavorka::Manual::Methods.

AUTHOR
Toby Inkster <tobyink@cpan.org>.

COPYRIGHT AND LICENCE
This software is copyright (c) 2013-2014, 2017 by Toby Inkster.

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

DISCLAIMER OF WARRANTIES
THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.