If you want, you can also explicitly specify the method names to be
used for reading and writing an attribute's value. This is
-particularly handy when you'd like an attribute to be publically
+particularly handy when you'd like an attribute to be publicly
readable, but only privately settable. For example:
has 'weight' => (
=head2 Constructor Parameters (init_arg)
By default, each attribute can be passed by name to the class's
-constructor. On occassion, you may want to use a different name for
+constructor. On occasion, you may want to use a different name for
the constructor parameter. You may also want to make an attribute
unsettable via the constructor.
=head1 A FEW MORE OPTIONS
Moose has lots of attribute options. The ones listed below are
-superceded by some more modern features, but are covered for the sake
+superseded by some more modern features, but are covered for the sake
of completeness.
=head2 The C<documentation> option
=head2 The C<auto_deref> Option
If your attribute is an array reference or hash reference, the
-C<auto_deref> option will make Moose de-reference the value when it is
+C<auto_deref> option will make Moose dereference the value when it is
returned from the reader method:
my %map = $object->mapping;
so it should contain keys matching your attributes' names (well,
C<init_arg>s).
-One common use for C<BUILDARGS> is to accomodate a non-hash(ref)
+One common use for C<BUILDARGS> is to accommodate a non-hash(ref)
calling style. For example, we might want to allow our Person class to
be called with a single argument of a social security number, C<<
Person->new($ssn) >>.
Without a C<BUILDARGS> method, Moose will complain, because it expects
a hash or hash reference. We can use the C<BUILDARGS> method to
-accomodate this calling style:
+accommodate this calling style:
sub BUILDARGS {
my $class = shift;
Moose provides a powerful introspection API built on top of
C<Class::MOP>. "MOP" stands for Meta-Object Protocol. In plainer
-english, a MOP is an API for performing introspection on classes,
+English, a MOP is an API for performing introspection on classes,
attributes, methods, and so on.
In fact, it is C<Class::MOP> that provides many of Moose's core
type 'FourCharacters' => where { defined $_ && length $_ == 4 };
In practice, this example is more or less the same as subtyping
-C<Str>, except you have to check defined-ness yourself.
+C<Str>, except you have to check definedness yourself.
It's hard to find a case where you wouldn't want to subtype a very
broad type like C<Defined>, C<Ref> or C<Object>.