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

NAME

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

VERSION

9       version 2.2011
10

DESCRIPTION

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

RECIPES

20   Basic Moose
21       These recipes will give you a good overview of Moose's capabilities,
22       starting with simple attribute declaration, and moving on to more
23       powerful features like laziness, types, type coercion, method
24       modifiers, and more.
25
26       Moose::Cookbook::Basics::Point_AttributesAndSubclassing
27           A simple Moose-based class. Demonstrates basic Moose attributes and
28           subclassing.
29
30       Moose::Cookbook::Basics::BankAccount_MethodModifiersAndSubclassing
31           A slightly more complex Moose class. Demonstrates using a method
32           modifier in a subclass.
33
34       Moose::Cookbook::Basics::BinaryTree_AttributeFeatures
35           Demonstrates several attribute features, including types, weak
36           references, predicates ("does this object have a foo?"), defaults,
37           laziness, and triggers.
38
39       Moose::Cookbook::Basics::Company_Subtypes
40           Introduces the creation and use of custom types, a "BUILD" method,
41           and the use of "override" in a subclass. This recipe also shows how
42           to model a set of classes that could be used to model companies,
43           people, employees, etc.
44
45       Moose::Cookbook::Basics::HTTP_SubtypesAndCoercion
46           This recipe covers more subtype creation, including the use of type
47           coercions.
48
49       Moose::Cookbook::Basics::Immutable
50           Making a class immutable greatly increases the speed of accessors
51           and object construction.
52
53       Moose::Cookbook::Basics::BinaryTree_BuilderAndLazyBuild - Builder
54       methods and lazy_build
55           The builder feature provides an inheritable and role-composable way
56           to provide a default attribute value.
57
58       Moose::Cookbook::Basics::Genome_OverloadingSubtypesAndCoercion
59           Demonstrates using operator overloading, coercion, and subtypes to
60           model how eye color is determined during reproduction.
61
62       Moose::Cookbook::Basics::Person_BUILDARGSAndBUILD
63           This recipe demonstrates the use of "BUILDARGS" and "BUILD" to hook
64           into object construction.
65
66       Moose::Cookbook::Basics::DateTime_ExtendingNonMooseParent
67           In this recipe, we make a Moose-based subclass of DateTime, a
68           module which does not use Moose itself.
69
70       Moose::Cookbook::Basics::Document_AugmentAndInner
71           Demonstrates the use of "augment" method modifiers, a way of
72           turning the usual method overriding style "inside-out".
73
74   Moose Roles
75       These recipes will show you how to use Moose roles.
76
77       Moose::Cookbook::Roles::Comparable_CodeReuse
78           Demonstrates roles, which are also sometimes known as traits or
79           mix-ins. Roles provide a method of code re-use which is orthogonal
80           to subclassing.
81
82       Moose::Cookbook::Roles::Restartable_AdvancedComposition
83           Sometimes you just want to include part of a role in your class.
84           Sometimes you want the whole role but one of its methods conflicts
85           with one in your class. With method exclusion and aliasing, you can
86           work around these problems.
87
88       Moose::Cookbook::Roles::ApplicationToInstance
89           In this recipe, we apply a role to an existing object instance.
90
91   Meta Moose
92       These recipes show you how to write your own meta classes, which lets
93       you extend the object system provided by Moose.
94
95       Moose::Cookbook::Meta::WhyMeta
96           If you're wondering what all this "meta" stuff is, and why you
97           should care about it, read this "recipe".
98
99       Moose::Cookbook::Meta::Labeled_AttributeTrait
100           Extending Moose's attribute metaclass is a great way to add
101           functionality. However, attributes can only have one metaclass.
102           Applying roles to the attribute metaclass lets you provide
103           composable attribute functionality.
104
105       Moose::Cookbook::Meta::Table_MetaclassTrait
106           This recipe takes the class metaclass we saw in the previous recipe
107           and reimplements it as a metaclass trait.
108
109       Moose::Cookbook::Meta::PrivateOrPublic_MethodMetaclass
110           This recipe shows a custom method metaclass that implements making
111           a method private.
112
113       Moose::Cookbook::Meta::GlobRef_InstanceMetaclass
114           This recipe shows an example of how you create your own meta-
115           instance class. The meta-instance determines the internal structure
116           of object instances and provide access to attribute slots.
117
118           In this particular instance, we use a blessed glob reference as the
119           instance instead of a blessed hash reference.
120
121       Hooking into immutabilization (TODO)
122           Moose has a feature known as "immutabilization". By calling
123           "__PACKAGE__->meta()->make_immutable()" after defining your class
124           (attributes, roles, etc), you tell Moose to optimize things like
125           object creation, attribute access, and so on.
126
127           If you are creating your own metaclasses, you may need to hook into
128           the immutabilization system. This cuts across a number of spots,
129           including the metaclass class, meta method classes, and possibly
130           the meta-instance class as well.
131
132           This recipe shows you how to write extensions which immutabilize
133           properly.
134
135   Extending Moose
136       These recipes cover some more ways to extend Moose, and will be useful
137       if you plan to write your own "MooseX" module.
138
139       Moose::Cookbook::Extending::ExtensionOverview
140           There are quite a few ways to extend Moose. This recipe provides an
141           overview of each method, and provides recommendations for when each
142           is appropriate.
143
144       Moose::Cookbook::Extending::Debugging_BaseClassRole
145           Many base object class extensions can be implemented as roles. This
146           example shows how to provide a base object class debugging role
147           that is applied to any class that uses a notional
148           "MooseX::Debugging" module.
149
150       Moose::Cookbook::Extending::Mooseish_MooseSugar
151           This recipe shows how to provide a replacement for "Moose.pm". You
152           may want to do this as part of the API for a "MooseX" module,
153           especially if you want to default to a new metaclass class or base
154           object class.
155

SNACKS

157       Moose::Cookbook::Snack::Keywords
158       Moose::Cookbook::Snack::Types
159

Legacy Recipes

161       These cover topics that are no longer considered best practice. We've
162       kept them in case in you encounter these usages in the wild.
163
164       Moose::Cookbook::Legacy::Labeled_AttributeMetaclass
165       Moose::Cookbook::Legacy::Table_ClassMetaclass
166       Moose::Cookbook::Legacy::Debugging_BaseClassReplacement
167

SEE ALSO

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

AUTHORS

172       ·   Stevan Little <stevan.little@iinteractive.com>
173
174       ·   Dave Rolsky <autarch@urth.org>
175
176       ·   Jesse Luehrs <doy@tozt.net>
177
178       ·   Shawn M Moore <code@sartak.org>
179
180       ·   יובל קוג'מן (Yuval Kogman) <nothingmuch@woobling.org>
181
182       ·   Karen Etheridge <ether@cpan.org>
183
184       ·   Florian Ragwitz <rafl@debian.org>
185
186       ·   Hans Dieter Pearcey <hdp@weftsoar.net>
187
188       ·   Chris Prather <chris@prather.org>
189
190       ·   Matt S Trout <mst@shadowcat.co.uk>
191
193       This software is copyright (c) 2006 by Infinity Interactive, Inc.
194
195       This is free software; you can redistribute it and/or modify it under
196       the same terms as the Perl 5 programming language system itself.
197
198
199
200perl v5.30.0                      2019-07-26                Moose::Cookbook(3)
Impressum