Add make_immutable to the SYNOPSIS
[gitmo/Mouse.git] / lib / Mouse.pm
index b7cc594..22827e5 100644 (file)
@@ -3,7 +3,7 @@ use 5.006_002;
 
 use Mouse::Exporter; # enables strict and warnings
 
-our $VERSION = '0.40_09';
+our $VERSION = '0.50_01';
 
 use Carp         qw(confess);
 use Scalar::Util qw(blessed);
@@ -61,33 +61,27 @@ sub has {
 
 sub before {
     my $meta = Mouse::Meta::Class->initialize(scalar caller);
-
     my $code = pop;
-
-    for (@_) {
-        $meta->add_before_method_modifier($_ => $code);
+    for my $name($meta->_collect_methods(@_)) {
+        $meta->add_before_method_modifier($name => $code);
     }
     return;
 }
 
 sub after {
     my $meta = Mouse::Meta::Class->initialize(scalar caller);
-
     my $code = pop;
-
-    for (@_) {
-        $meta->add_after_method_modifier($_ => $code);
+    for my $name($meta->_collect_methods(@_)) {
+        $meta->add_after_method_modifier($name => $code);
     }
     return;
 }
 
 sub around {
     my $meta = Mouse::Meta::Class->initialize(scalar caller);
-
     my $code = pop;
-
-    for (@_) {
-        $meta->add_around_method_modifier($_ => $code);
+    for my $name($meta->_collect_methods(@_)) {
+        $meta->add_around_method_modifier($name => $code);
     }
     return;
 }
@@ -157,7 +151,6 @@ sub init_meta {
     return $meta;
 }
 
-
 1;
 __END__
 
@@ -167,7 +160,7 @@ Mouse - Moose minus the antlers
 
 =head1 VERSION
 
-This document describes Mouse version 0.40_09
+This document describes Mouse version 0.50_01
 
 =head1 SYNOPSIS
 
@@ -183,6 +176,9 @@ This document describes Mouse version 0.40_09
         $self->y(0);
     }
 
+
+    __PACKAGE__->meta->make_immutable();
+
     package Point3D;
     use Mouse;
 
@@ -195,6 +191,8 @@ This document describes Mouse version 0.40_09
         $self->z(0);
     };
 
+    __PACKAGE__->meta->make_immutable();
+
 =head1 DESCRIPTION
 
 L<Moose> is wonderful. B<Use Moose instead of Mouse.>
@@ -250,16 +248,18 @@ Returns this class' metaclass instance.
 
 Sets this class' superclasses.
 
-=head2 C<< before (method|methods) => CodeRef >>
+=head2 C<< before (method|methods|regexp) => CodeRef >>
 
 Installs a "before" method modifier. See L<Moose/before>.
 
-=head2 C<< after (method|methods) => CodeRef >>
+=head2 C<< after (method|methods|regexp) => CodeRef >>
 
 Installs an "after" method modifier. See L<Moose/after>.
-=head2 C<< around (method|methods) => CodeRef >>
+
+=head2 C<< around (method|methods|regexp) => CodeRef >>
 
 Installs an "around" method modifier. See L<Moose/around>.
+
 =head2 C<< has (name|names) => parameters >>
 
 Adds an attribute (or if passed an arrayref of names, multiple attributes) to
@@ -269,10 +269,16 @@ this class. Options:
 
 =item C<< is => ro|rw|bare >>
 
-If specified, inlines a read-only/read-write accessor with the same name as
+The I<is> option accepts either I<rw> (for read/write), I<ro> (for read
+only) or I<bare> (for nothing). These will create either a read/write accessor
+or a read-only accessor respectively, using the same name as the C<$name> of
 the attribute.
 
-=item C<< isa => TypeConstraint >>
+If you need more control over how your accessors are named, you can
+use the C<reader>, C<writer> and C<accessor> options, however if you
+use those, you won't need the I<is> option.
+
+=item C<< isa => TypeName | ClassName >>
 
 Provides type checking in the constructor and accessor. The following types are
 supported. Any unknown type is taken to be a class check
@@ -284,6 +290,17 @@ supported. Any unknown type is taken to be a class check
 
 For more documentation on type constraints, see L<Mouse::Util::TypeConstraints>.
 
+=item C<< does => RoleName >>
+
+This will accept the name of a role which the value stored in this attribute
+is expected to have consumed.
+
+=item C<< coerce => Bool >>
+
+This will attempt to use coercion with the supplied type constraint to change
+the value passed into any accessors or constructors. You B<must> have supplied
+a type constraint in order for this to work. See L<Moose::Cookbook::Basics::Recipe5>
+for an example.
 
 =item C<< required => Bool >>
 
@@ -320,12 +337,12 @@ Lets you specify a method name for installing a clearer method, which clears
 the attribute's value from the instance. On the next read, lazy or builder will
 be invoked.
 
-=item C<< handles => HashRef|ArrayRef >>
+=item C<< handles => HashRef|ArrayRef|Regexp >>
 
 Lets you specify methods to delegate to the attribute. ArrayRef forwards the
 given method names to method calls on the attribute. HashRef maps local method
 names to remote method names called on the attribute. Other forms of
-L</handles>, such as regular expression and coderef, are not yet supported.
+L</handles>, such as RoleName and CodeRef, are not yet supported.
 
 =item C<< weak_ref => Bool >>
 
@@ -384,6 +401,22 @@ You may use L</extends> to replace the superclass list.
 Please unimport Mouse (C<no Mouse>) so that if someone calls one of the
 keywords (such as L</extends>) it will break loudly instead breaking subtly.
 
+=head1 CAVEATS
+
+If you use Mouse::XS you might see a fatal error on callbacks
+which include C<eval 'BEGIN{ die }'>, which typically occurs in such code
+as C<eval 'use NotInstalledModule'>. This is not
+a bug in Mouse. In fact, it is a bug in Perl (RT #69939).
+
+To work around this problem, surround C<eval STRING> with C<eval BLOCK>:
+
+    sub callback {
+        # eval 'use NotInstalledModule';       # NG
+        eval{ eval 'use NotInstalledModule' }; # OK
+    }
+
+It seems ridiculous, but it works as you expected.
+
 =head1 SOURCE CODE ACCESS
 
 We have a public git repository:
@@ -430,7 +463,7 @@ interface at L<http://rt.cpan.org/Public/Dist/Display.html?Name=Mouse>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2008-2009 Infinity Interactive, Inc.
+Copyright (c) 2008-2010 Infinity Interactive, Inc.
 
 http://www.iinteractive.com/