Moose::Cookbook - How to cook a Moose


Moose::Cookbook - How to cook a Moose


The Moose cookbook is a series of recipes taken from the Moose test suite. Each recipe presents some code, which demonstrates some of the features of Moose, and then proceeds to explain the details of the code.

We also provide a the Moose::Cookbook::FAQ manpage and a the Moose::Cookbook::WTF manpage for common questions and problems people have with Moose.


Basic Moose

the Moose::Cookbook::Recipe1 manpage - The (always classic) Point example
A simple Moose-based class. Demonstrated Moose attributes and subclassing.

the Moose::Cookbook::Recipe2 manpage - A simple BankAccount example
A slightly more complex Moose class. Demonstrates using a method modifier in a subclass.

the Moose::Cookbook::Recipe3 manpage - A lazy BinaryTree example
Demonstrates several attribute features, including types, weak references, predicates (``does this object have a foo?''), defaults, and lazy attribute construction.

the Moose::Cookbook::Recipe4 manpage - Subtypes, and modeling a simple Company class hierarchy
Introduces the creation and use of custom types, a BUILD method, and the use of override in a subclass.

the Moose::Cookbook::Recipe5 manpage - More subtypes, coercion in a Request class
More type examples, including the use of type coercions.

the Moose::Cookbook::Recipe6 manpage - The augment/inner example
Demonstrates the use of augment method modifiers, a way of turning the usual method overriding style ``inside-out''.

the Moose::Cookbook::Recipe7 manpage - Making Moose fast with immutable
Making a class immutable greatly increases the speed of accessors and object construction.

the Moose::Cookbook::Recipe8 manpage - Managing complex relations with trigger (TODO)
abstract goes here

Work off of this

the Moose::Cookbook::Recipe9 manpage - Builder methods and lazy_build
The builder feature provides an inheritable and role-composable way to provide a default attribute value.

Moose Roles

the Moose::Cookbook::Recipe10 manpage - The Moose::Role example
Demonstrates roles, which are also sometimes known as traits or mix-ins. Roles provide a method of code re-use which is orthogonal to subclassing.

the Moose::Cookbook::Recipe11 manpage - Advanced Role Composition - method exclusion and aliasing
Sometimes you just want to include part of a role in your class. Sometimes you want the whole role but one if its methods conflicts with one in your class. With method exclusion and aliasing, you can work around these problems.

the Moose::Cookbook::Recipe12 manpage - Runtime Role Composition (TODO)
abstract goes here

Meta Moose

the Moose::Cookbook::Recipe20 manpage - Welcome to the meta-world (TODO)
abstract goes here

the Moose::Cookbook::Recipe21 manpage - The meta-attribute example
One way to extend Moose is to provide your own attribute metaclasses. Attribute metaclasses let you extend attribute declarations (with has) and behavior to provide additional attribute functionality.

the Moose::Cookbook::Recipe22 manpage - The meta-attribute trait example (TODO)
abstract goes here

the Moose::Cookbook::Recipe23 manpage - The meta-instance example (TODO)
abstract goes here

the Moose::Cookbook::Recipe24 manpage - The meta-class example (TODO)
abstract goes here


the Moose::Cookbook::Snack::Types manpage



Stevan Little <>


Copyright 2006-2008 by Infinity Interactive, Inc.

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

 Moose::Cookbook - How to cook a Moose