From: Dave Rolsky Date: Sat, 10 May 2008 17:03:43 +0000 (+0000) Subject: A few tweaks. X-Git-Tag: 0_55~185 X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=1d996f467ff31e95994111e8a4e1cfdbecd0aa0b;p=gitmo%2FMoose.git A few tweaks. Mention Class::MOP for introspection. A few wording tweaks. --- diff --git a/lib/Moose/Cookbook/Snack/Perl5ObjsVsMooseObjs.pod b/lib/Moose/Cookbook/Snack/Perl5ObjsVsMooseObjs.pod index 51518ec..d884be6 100644 --- a/lib/Moose/Cookbook/Snack/Perl5ObjsVsMooseObjs.pod +++ b/lib/Moose/Cookbook/Snack/Perl5ObjsVsMooseObjs.pod @@ -111,6 +111,10 @@ The proper way to do this with Moose is C<$object-Emeta-Ename>; # an object's class name in Moose print "I am a " . $demo->meta->name . " type of object\n"; +Moose builds on C to provide a rich introspection API that +goes way beyond just getting the class name. Check out the +C documentation for more details. + =head3 Difference #4 - Assigning values to Moose object attributes When you wish to assign a value directly to an object attribute for a Perl 5 @@ -137,16 +141,16 @@ labeld B, but briefly: # later on... $self->x(0); -The syntax shown for the Perl 5 object (C<$self-E{x} = 0>) will also work -on the Moose object, as Moose objects are blessed hashes just like the average -Perl object is. However, if you access the object's hash reference directly -via the latter syntax: - -1) Moose will no longer be to enforce having that attribute be read-only if -you used (C ro>) in the object's declaration. +The syntax shown for the Perl 5 object (C<$self-E{x} = 0>) will +also work on the Moose object, as Moose objects are, by default, +blessed hashes just like the average Perl object is. However, if you +access the object's hash reference directly via the latter syntax you +will have several problems. -2) You break that object's encapsulation, which is one of the reasons you want -to use objects in the first place, right? +First, Moose, will no longer be able to enforce attribute constraints, +such as read-only or type constraints. Second, you've broken that +object's encapsulation, and encapsulation is one of the reasons you +want to use objects in the first place, right? =head1 SEE ALSO