Giter VIP home page Giter VIP logo

mo's Introduction

Name

Mo - Micro Objects. Mo is less.

Synopsis

package Less;
use Mo;
extends 'Nothing';

has something => ();

Description

use Mo. Mo is less. Much less.

Moose is huge. 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.

To get just a little Mo from Mo, use "Mo Features" below.

Core Features

This is what you get. Nothing Mo.

new method

Mo provides a new object constructor. You pass it a list of name/value pairs and it returns a new object.

Constructor will not call BUILD methods. This is available using the Mo::build feature.

extends

Mo exports the extends keyword, to declare your parent class. Mo::Object itself is your default parent class.

Mo only supports single inheritance. If you need multiple inheritance or roles, you should upgrade to Moo.

has

Mo exports a has keyword, to generate accessors.

These accessors always support both get and set operations. That's it.

has name => ();
has thing => (foo => 'bar');  # arguments silently ignored

All arguments passed to has are ignored. This makes it easier to switch between Mo and Moo, without having to change all your accessors.

strict and warnings

Mo turns on use strict and use warnings for you.

Embeddable

Mo is tiny. It is compressed into a single line. You can easily inline it in your code, should you want to do that. See Mo::Inline for more information, including a utility that will do it for you.

Mo Features

Mo is the bare minimum needed for Perl OO. Many times you'll want just a couple more features. Don't worry. Mo's got you covered:

use Mo qw'build default builder coerce is required';
has name1 => ( default => sub { 'Joe' } );
has name2 => ( builder => 'name_builder' );
has name3 => ( coerce => sub {$_[0]} );
has name4 => ( is => 'ro' );
has name4 => ( required => 1 );
sub BUILD {
    my $self = shift;
    ...
}

Mo simply loads the feature classes Mo::build, Mo::default, Mo::builder, Mo::coerce, Mo::is and Mo::required. The first one supports BUILD constructing and the other three add their magics to has. A Mo::Feature module can enhance new, extends and has, and also add new export subs, or remove existing ones. Features can also be combined for a single accessor. See Mo::Features for a list of all the features and for an explanation of the Feature API..

See

Mo::Features

Mo::Inlining

Mo::Hacking

Mo::Design

Status

Build Status

Authors

Ingy döt Net <[email protected]>

Damien 'dams' Krotkine <[email protected]>

Matt S. Trout (mst) <[email protected]>

Christian Walde <[email protected]>

Alessandro Ranellucci (aar/alexrj) <[email protected]>

Carlos Lima (priodev) <[email protected]>

Copyright and License

Copyright (c) 2011-2013. 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

mo's People

Contributors

carloslima avatar ingydotnet avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.