Stevan Little > Moose-0.54 > Moose::Cookbook


Annotate this POD


New  10
Open  39
Stalled  5
View/Report Bugs
Source   Latest Release: Moose-2.1210


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 Moose::Cookbook::FAQ and a Moose::Cookbook::WTF for common questions and problems people have with Moose.


Basic Moose

Moose::Cookbook::Recipe1 - The (always classic) Point example

A simple Moose-based class. Demonstrated Moose attributes and subclassing.

Moose::Cookbook::Recipe2 - A simple BankAccount example

A slightly more complex Moose class. Demonstrates using a method modifier in a subclass.

Moose::Cookbook::Recipe3 - A lazy BinaryTree example

Demonstrates several attribute features, including types, weak references, predicates ("does this object have a foo?"), defaults, and lazy attribute construction.

Moose::Cookbook::Recipe4 - 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.

Moose::Cookbook::Recipe5 - More subtypes, coercion in a Request class

More type examples, including the use of type coercions.

Moose::Cookbook::Recipe6 - The augment/inner example

Demonstrates the use of augment method modifiers, a way of turning the usual method overriding style "inside-out".

Moose::Cookbook::Recipe7 - Making Moose fast with immutable

Making a class immutable greatly increases the speed of accessors and object construction.

Moose::Cookbook::Recipe8 - Managing complex relations with trigger (TODO)

abstract goes here

Work off of this

Moose::Cookbook::Recipe9 - Builder methods and lazy_build

The builder feature provides an inheritable and role-composable way to provide a default attribute value.

Moose Roles

Moose::Cookbook::Recipe10 - 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.

Moose::Cookbook::Recipe11 - 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.

Moose::Cookbook::Recipe12 - Runtime Role Composition (TODO)

abstract goes here

Meta Moose

Moose::Cookbook::Recipe20 - Welcome to the meta-world (TODO)

abstract goes here

Moose::Cookbook::Recipe21 - 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.

Moose::Cookbook::Recipe22 - The meta-attribute trait example

Extending Moose's attribute metaclass is a great way to add functionality. However, attributes can only have one metaclass. Applying roles to the attribute metaclass lets you provide composable attribute functionality.

Moose::Cookbook::Recipe23 - The meta-instance example (TODO)

abstract goes here

Moose::Cookbook::Recipe24 - The meta-class example (TODO)

abstract goes here





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.

syntax highlighting: