clarify is => 'lazy' docs to explain that the rw+lazy footgun still works
[gitmo/Moo.git] / lib / Moo.pm
index 8061541..37d0bf8 100644 (file)
@@ -5,7 +5,7 @@ use Moo::_Utils;
 use B 'perlstring';
 use Sub::Defer ();
 
-our $VERSION = '1.000007'; # 1.0.7
+our $VERSION = '1.000008'; # 1.0.8
 $VERSION = eval $VERSION;
 
 require Moo::sification;
@@ -25,8 +25,7 @@ sub import {
   if ($Moo::Role::INFO{$target} and $Moo::Role::INFO{$target}{is_role}) {
     die "Cannot import Moo into a role";
   }
-  return if $MAKERS{$target}; # already exported into this package
-  $MAKERS{$target} = { is_class => 1 };
+  $MAKERS{$target} ||= {};
   _install_tracked $target => extends => sub {
     $class->_set_superclasses($target, @_);
     $class->_maybe_reset_handlemoose($target);
@@ -59,6 +58,8 @@ sub import {
       return;
     };
   }
+  return if $MAKERS{$target}{is_class}; # already exported into this package
+  $MAKERS{$target}{is_class} = 1;
   {
     no strict 'refs';
     @{"${target}::ISA"} = do {
@@ -429,7 +430,9 @@ C<lazy> generates a reader like C<ro>, but also sets C<lazy> to 1 and
 C<builder> to C<_build_${attribute_name}> to allow on-demand generated
 attributes.  This feature was my attempt to fix my incompetence when
 originally designing C<lazy_build>, and is also implemented by
-L<MooseX::AttributeShortcuts>.
+L<MooseX::AttributeShortcuts>. There is, however, nothing to stop you
+using C<lazy> and C<builder> yourself with C<rwp> or C<rw> - it's just that
+this isn't generally a good idea so we don't provide a shortcut for it.
 
 C<rwp> generates a reader like C<ro>, but also sets C<writer> to
 C<_set_${attribute_name}> for attributes that are designed to be written
@@ -556,8 +559,14 @@ Moo will call
 
   $self->$builder;
 
+The following features come from L<MooseX::AttributeShortcuts>:
+
 If you set this to just C<1>, the builder is automatically named
-C<_build_${attr_name}>.  This feature comes from L<MooseX::AttributeShortcuts>.
+C<_build_${attr_name}>.
+
+If you set this to a coderef or code-convertible object, that variable will be
+installed under C<$class::_build_${attr_name}> and the builder set to the same
+name.
 
 =item * C<clearer>
 
@@ -804,6 +813,8 @@ ilmari - Dagfinn Ilmari MannsÃ¥ker (cpan:ILMARI) <ilmari@ilmari.org>
 
 tobyink - Toby Inkster (cpan:TOBYINK) <tobyink@cpan.org>
 
+haarg - Graham Knop (cpan:HAARG) <haarg@cpan.org>
+
 =head1 COPYRIGHT
 
 Copyright (c) 2010-2011 the Moo L</AUTHOR> and L</CONTRIBUTORS>