1Moose::Cookbook(3)    User Contributed Perl Documentation   Moose::Cookbook(3)
2
3
4

NAME

6       Moose::Cookbook - How to cook a Moose
7

DESCRIPTION

9       The Moose cookbook is a series of recipes showing various Moose
10       features. Most recipes present some code demonstrating some feature,
11       and then explain the details of the code.
12
13       You should probably read the Moose::Manual first. The manual explains
14       Moose concepts without being too code-heavy.
15

RECIPES

17   Basic Moose
18       These recipes will give you a good overview of Moose's capabilities,
19       starting with simple attribute declaration, and moving on to more
20       powerful features like laziness, types, type coercion, method
21       modifiers, and more.
22
23       Moose::Cookbook::Basics::Recipe1 - The (always classic) Point example
24           A simple Moose-based class. Demonstrates Moose attributes and
25           subclassing.
26
27       Moose::Cookbook::Basics::Recipe2 - A simple BankAccount example
28           A slightly more complex Moose class. Demonstrates using a method
29           modifier in a subclass.
30
31       Moose::Cookbook::Basics::Recipe3 - A lazy BinaryTree example
32           Demonstrates several attribute features, including types, weak
33           references, predicates ("does this object have a foo?"), defaults,
34           laziness, and triggers.
35
36       Moose::Cookbook::Basics::Recipe4 - Subtypes, and modeling a simple
37       Company class hierarchy
38           Introduces the creation and use of custom types, a "BUILD" method,
39           and the use of "override" in a subclass.
40
41       Moose::Cookbook::Basics::Recipe5 - More subtypes, coercion in a Request
42       class
43           More type examples, including the use of type coercions.
44
45       Moose::Cookbook::Basics::Recipe6 - The augment/inner example
46           Demonstrates the use of "augment" method modifiers, a way of
47           turning the usual method overriding style "inside-out".
48
49       Moose::Cookbook::Basics::Recipe7 - Making Moose fast with immutable
50           Making a class immutable greatly increases the speed of accessors
51           and object construction.
52
53       Moose::Cookbook::Basics::Recipe8 - Builder methods and lazy_build
54           The builder feature provides an inheritable and role-composable way
55           to provide a default attribute value.
56
57       Moose::Cookbook::Basics::Recipe9 - Operator overloading, subtypes, and
58       coercion
59           Demonstrates using operator overloading, coercion, and subtypes to
60           model how eye color is determined during reproduction.
61
62       Moose::Cookbook::Basics::Recipe10 - Using BUILDARGS and BUILD to hook
63       into object construction
64           This recipe demonstrates the use of "BUILDARGS" and "BUILD" to hook
65           into object construction.
66
67       Moose::Cookbook::Basics::Recipe11 - Extending a non-Moose base class
68           In this recipe, we make a Moose-based subclass of DateTime, a
69           module which does not use Moose itself.
70
71   Moose Roles
72       These recipes will show you how to use Moose roles.
73
74       Moose::Cookbook::Roles::Recipe1 - The Moose::Role example
75           Demonstrates roles, which are also sometimes known as traits or
76           mix-ins. Roles provide a method of code re-use which is orthogonal
77           to subclassing.
78
79       Moose::Cookbook::Roles::Recipe2 - Advanced Role Composition - method
80       exclusion and aliasing
81           Sometimes you just want to include part of a role in your class.
82           Sometimes you want the whole role but one of its methods conflicts
83           with one in your class. With method exclusion and aliasing, you can
84           work around these problems.
85
86       Moose::Cookbook::Roles::Recipe3 - Applying a role to an object instance
87           In this recipe, we apply a role to an existing object instance.
88
89   Meta Moose
90       These recipes show you how to write your own meta classes, which lets
91       you extend the object system provided by Moose.
92
93       Moose::Cookbook::Meta::Recipe1 - Welcome to the meta-world (Why Go
94       Meta?)
95           If you're wondering what all this "meta" stuff is, and why you
96           should care about it, read this "recipe".
97
98       Moose::Cookbook::Meta::Recipe2 - A meta-attribute, attributes with
99       labels
100           One way to extend Moose is to provide your own attribute
101           metaclasses. Attribute metaclasses let you extend attribute
102           declarations (with "has") and behavior to provide additional
103           attribute functionality.
104
105       Moose::Cookbook::Meta::Recipe3 - Labels implemented via attribute
106       traits
107           Extending Moose's attribute metaclass is a great way to add
108           functionality. However, attributes can only have one metaclass.
109           Applying roles to the attribute metaclass lets you provide
110           composable attribute functionality.
111
112       Moose::Cookbook::Meta::Recipe4 - Adding a "table" attribute to the
113       metaclass
114           If you want to store more information about your classes, you'll
115           have to extend "Moose::Meta::Class". Doing so is simple, but you'll
116           probably also want to provide some sugar, so see
117           Moose::Cookbook::Extending::Recipe2 as well.
118
119       Moose::Cookbook::Meta::Recipe5 - The "table" attribute implemented as a
120       metaclass trait
121           This recipe takes the class metaclass we saw in the previous recipe
122           and reimplements it as a metaclass trait.
123
124       Moose::Cookbook::Meta::Recipe6 - A method metaclass for marking methods
125       public or private
126           This recipe shows a custom method metaclass that implements making
127           a method private.
128
129       Moose::Cookbook::Meta::Recipe7 - Using a blessed array reference as an
130       object instance
131           This recipe shows an example of how you create your own meta-
132           instance class. The meta-instance determines the internal structure
133           of object instances and provide access to attribute slots.
134
135       Moose::Cookbook::Meta::Recipe8 - Hooking into immutabilization (TODO)
136           Moose has a feature known as "immutabilization". By calling
137           "__PACKAGE__->meta()->make_immutable()" after defining your class
138           (attributes, roles, etc), you tell Moose to optimize things like
139           object creation, attribute access, and so on.
140
141           If you are creating your own metaclasses, you may need to hook into
142           the immutabilization system. This cuts across a number of spots,
143           including the metaclass class, meta method classes, and possibly
144           the meta-instance class as well.
145
146           This recipe shows you how to write extensions which immutabilize
147           properly.
148
149   Extending Moose
150       These recipes cover some more ways to extend Moose, and will be useful
151       if you plan to write your own "MooseX" module.
152
153       Moose::Cookbook::Extending::Recipe1 - Moose extension overview
154           There are quite a few ways to extend Moose. This recipe provides an
155           overview of each method, and provides recommendations for when each
156           is appropriate.
157
158       Moose::Cookbook::Extending::Recipe2 - Providing a base object class
159       role
160           Many base object class extensions can be implemented as roles. This
161           example shows how to provide a base object class debugging role
162           that is applied to any class that uses a notional
163           "MooseX::Debugging" module.
164
165       Moose::Cookbook::Extending::Recipe3 - Providing an alternate base
166       object class
167           You may find that you want to provide an alternate base object
168           class along with a meta extension, or maybe you just want to add
169           some functionality to all your classes without typing "extends
170           'MyApp::Base'" over and over.
171
172       Moose::Cookbook::Extending::Recipe4 - Acting like Moose.pm and
173       providing sugar Moose-style
174           This recipe shows how to provide a replacement for "Moose.pm". You
175           may want to do this as part of the API for a "MooseX" module,
176           especially if you want to default to a new metaclass class or base
177           object class.
178

SNACKS

180       Moose::Cookbook::Snack::Keywords
181       Moose::Cookbook::Snack::Types
182

SEE ALSO

184       <http://www.gsph.com/index.php?Lang=En&ID=291>
185

AUTHOR

187       Stevan Little <stevan@iinteractive.com>
188
190       Copyright 2006-2010 by Infinity Interactive, Inc.
191
192       <http://www.iinteractive.com>
193
194       This library is free software; you can redistribute it and/or modify it
195       under the same terms as Perl itself.
196
197
198
199perl v5.12.2                      2010-08-21                Moose::Cookbook(3)
Impressum