added documtentation for attributes overloading
[gitmo/Moo.git] / lib / Moo.pm
index 37d0bf8..42da790 100644 (file)
@@ -165,7 +165,7 @@ sub _constructor_maker_for {
         construction_string => (
           $moo_constructor
             ? ($con ? $con->construction_string : undef)
-            : ('$class->'.$target.'::SUPER::new(@_)')
+            : ('$class->'.$target.'::SUPER::new($class->can(q[FOREIGNBUILDARGS]) ? $class->FOREIGNBUILDARGS(@_) : @_)')
         ),
         subconstructor_handler => (
           '      if ($Moo::MAKERS{$class}) {'."\n"
@@ -212,7 +212,7 @@ Moo - Minimalist Object Orientation (with Moose compatiblity)
    isa => sub {
      die "Only SWEET-TREATZ supported!" unless $_[0] eq 'SWEET-TREATZ'
    },
-);
+ );
 
  has pounds => (
    is  => 'rw',
@@ -415,6 +415,15 @@ class.  An error will be raised if these roles have conflicting methods.
 
 Declares an attribute for the class.
 
+ package Bar;
+ extends 'Foo'; # Foo has an 'attr' attribute
+
+ has '+attr' => (
+   default => sub { "blah" },
+ );
+
+Using the C<+> notation, it's possible to override an attribute.
+
 The options for C<has> are as follows:
 
 =over 2
@@ -511,11 +520,11 @@ Takes a hashref
    un => 'one',
  }
 
-=item * trigger
+=item * C<trigger>
 
 Takes a coderef which will get called any time the attribute is set. This
-includes the constructor. Coderef will be invoked against the object with the
-new value as an argument.
+includes the constructor, but not default or built values. Coderef will be
+invoked against the object with the new value as an argument.
 
 If you set this to just C<1>, it generates a trigger which calls the
 C<_trigger_${attr_name}> method on C<$self>. This feature comes from
@@ -781,8 +790,18 @@ to Moo by providing a more Moose-like interface.
 
 Users' IRC: #moose on irc.perl.org
 
+=for html <a href="http://chat.mibbit.com/#moose@irc.perl.org">(click for instant chatroom login)</a>
+
 Development and contribution IRC: #web-simple on irc.perl.org
 
+=for html <a href="http://chat.mibbit.com/#web-simple@irc.perl.org">(click for instant chatroom login)</a>
+
+Bugtracker: L<http://rt.cpan.org/NoAuth/Bugs.html?Dist=Moo>
+
+Git repository: L<git://git.shadowcat.co.uk/gitmo/Moo.git>
+
+Git web access: L<http://git.shadowcat.co.uk/gitweb/gitweb.cgi?p=gitmo/Moo.git>
+
 =head1 AUTHOR
 
 mst - Matt S. Trout (cpan:MSTROUT) <mst@shadowcat.co.uk>
@@ -815,6 +834,8 @@ tobyink - Toby Inkster (cpan:TOBYINK) <tobyink@cpan.org>
 
 haarg - Graham Knop (cpan:HAARG) <haarg@cpan.org>
 
+mattp - Matt Phillips (cpan:MATTP) <mattp@cpan.org>
+
 =head1 COPYRIGHT
 
 Copyright (c) 2010-2011 the Moo L</AUTHOR> and L</CONTRIBUTORS>
@@ -823,6 +844,6 @@ as listed above.
 =head1 LICENSE
 
 This library is free software and may be distributed under the same terms
-as perl itself.
+as perl itself. See L<http://dev.perl.org/licenses/>.
 
 =cut