Take me over?
The maintainer of this distribution is looking for someone to take over!
If you're interested then please contact them via
email.
NAME
mixin::with - declaring a mix-in class
SYNOPSIS
package Dog::Retriever;
use mixin::with 'Dog';
DESCRIPTION
mixin::with is used to declare mix-in classes.
Creating a mixin class.
There are three critical differences between a normal subclass and one intended to be mixin.
- 1. It can have no superclasses.
- 2. It can have no private methods. Instead, use private functions.
-
_private($self, @args)
instead of$self-
_private(@args);> - 3. The mixin class is useless on it's own.
-
You can't just "use Dog::Retriever" alone and expect it to do anything useful. It must be mixed.
Mixin classes useful for those that add new functionality to an existing class. If you find yourself doing:
package Foo::ExtraStuff;
use base 'Foo';
package Bar;
use base qw(Foo Foo::ExtraStuff);
it's a good indication that Foo::ExtraStuff might do better as a mixin.
How?
Basic usage is simple:
package Foo::Extra;
use mixin::with 'Foo';
sub new_thing {
my($self) = shift;
...normal method...
}
use mixin::with 'Foo'
is similar to subclassing from 'Foo'.
All public methods of Foo::Extra will be mixed in. mixin::with considers all methods that don't start with an '_' as public.
AUTHOR
Michael G Schwern <schwern@pobox.com>