From: Dave Rolsky Date: Tue, 3 Feb 2009 16:39:00 +0000 (+0000) Subject: Small tweaks in the Construction manual X-Git-Tag: 0.66~13 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=088f068fe5e3896da8ad0b9730da0d4e2a498e12;p=gitmo%2FMoose.git Small tweaks in the Construction manual --- diff --git a/lib/Moose/Manual/Construction.pod b/lib/Moose/Manual/Construction.pod index d71fb6b..10c1315 100644 --- a/lib/Moose/Manual/Construction.pod +++ b/lib/Moose/Manual/Construction.pod @@ -9,10 +9,10 @@ Moose::Manual::Classes - Object construction (and destruction) with Moose B method for your classes!> When you C in your class, you will become a subclass of -C, which provides a C method for you. And if you +C, which provides a C method for you. If you follow our recommendations in L and make your class immutable, then you actually get a class-specific C -method genreated in your class. +method "inlined" in your class. =head1 OBJECT CONSTRUCTION AND ATTRIBUTES @@ -24,22 +24,22 @@ you're ready to start creating objects! =head1 OBJECT CONSTRUCTION HOOKS -Sometimes you need to hook into object construction. Some common needs -are validating an object's state, logging, and allowing non-hash(ref) -constructor arguments. Moose provides hooks for these needs with the -C and C methods. +Moose lets you hook into object construction. You can validate an +object's state, do logging, or maybe allow non-hash(ref) constructor +arguments. You can do this by creating C and/or C +methods. -If these are defined in your class, then Moose will arrange for them -to be called as part of the object construction process. +If these methods exist in your class, Moose will arrange for them to +be called as part of the object construction process. =head2 BUILDARGS -The C method is called I an object is created, and -is therefore called as a class method. It will receive all of the -arguments that were passed to C I. Your C -method must then return a hash reference. This hash reference will be -used to construct the object, so it should contain keys matching your -attributes' names (well, Cs). +The C method is called as a class method I an +object is created. It will receive all of the arguments that were +passed to C I, and is expected to return a hash +reference. This hash reference will be used to construct the object, +so it should contain keys matching your attributes' names (well, +Cs). One common use for C is to accomodate a non-hash(ref) calling style. For example, we might want to allow our Person class to @@ -63,15 +63,15 @@ accomodate this calling style: Note the call to C. This will call the default C in C. This method handles distinguishing -between a hash reference and a plain hash, so you don't have to. +between a hash reference and a plain hash for you. =head2 BUILD The C method is called I an object is created. There are -many potential uses for a C method. One of the most common is -to check that the object state makes sense. While we can validate -individual attributes through the use of types, we can't validate the -state of a whole object that way. +ways to use a C method. One of the most common is to check that +the object state is valid. While we can validate individual attributes +through the use of types, we can't validate the state of a whole +object that way. sub BUILD { my $self = shift; @@ -115,7 +115,7 @@ C methods in your hierarchy to be called, from most to least specific. In most cases, Perl's built-in garbage collection is sufficient, and -you won't need ot provide a C method. +you won't need to provide a C method. =head1 AUTHOR