NAME
Mo - Micro Objects. Mo is less.
SYNOPSIS
package Less;
use Mo;
extends 'Nothing';
has 'something' => (
is => 'rw',
default => sub {
my $self = shift;
$self->build_something;
},
);
sub BUILD {
my $self = shift;
$self->SUPER::BUILD();
# ...
}
DESCRIPTION
use Mo. Mo is less. Much less.
Moose led to Mouse led to Moo led to Mo. M is nothing. Mo is more. Not much.
When Moo is more than you need, drop an 'o' and get some Mo.
FEATURES
This is what you get. Nothing Mo.
newmethod-
Mo provides a
newobject constructor. You pass it a list of name/value pairs and it returns a new object.After creation, it will call the
BUILDmethod for all its parents and itself, if any of the classes have aBUILDmethod. extends-
Mo exports the
extendskeyword, to name your parent class.Moitself is your default parent class, of course. You can have multiple parent classes. has-
Mo exports a
haskeyword, to generate accessors.These accessors support
getandsetoperations and allows adefault. That's it.has 'name1'; has 'name2' => ( default => sub { 'Joe' } ); has 'name3' => ( builder => 'name_builder' );hastakes arguments after the name. Here is what it currently supports:- default
-
Must be a code reference. The object instance is passed in, and it should return the default value for this attribute.
defaultis always called lazily. ie It is called when you try to get the value and it does not(exists()). - builder
-
Must be a method name. This method should return the default value for this attribute.
builderis always called lazily.
Any other arguments are ignored. This lets you switch from Moo to Mo and back, without having to change all your accessors.
strictandwarnings-
Mo turns on
use strictanduse warningsfor you. - Embeddable
-
Mo is tiny. It is currently < 15 lines, < 80 chars each.
You could easily inline it in your code, if you wanted to.
AUTHORS
Ingy döt Net <ingy@cpan.org>
Damien 'dams' Krotkine <dams@cpan.org>
COPYRIGHT AND LICENSE
Copyright (c) 2011. Ingy döt Net.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
See http://www.perl.com/perl/misc/Artistic.html