use B 'perlstring';
use Sub::Defer ();
-our $VERSION = '1.000008'; # 1.0.8
+our $VERSION = '1.001000'; # 1.1.0
$VERSION = eval $VERSION;
require Moo::sification;
to use them in L<Moose> code without anybody ever noticing you aren't using
L<Moose> everywhere.
+L<Moo> will also create L<Moose type constraints|Moose::Manual::Types> for
+classes and roles, so that C<< isa => 'MyClass' >> and C<< isa => 'MyRole' >>
+work the same as for L<Moose> classes and roles.
+
Extending a L<Moose> class or consuming a L<Moose::Role> will also work.
So will extending a L<Mouse> class or consuming a L<Mouse::Role> - but note
die "$_[0] is not a number!" unless looks_like_number $_[0]
},
+Note that the return value is ignored, only whether the sub lives or
+dies matters.
+
L<Sub::Quote aware|/SUB QUOTE AWARE>
Since L<Moo> does B<not> run the C<isa> check before C<coerce> if a coercion
if the attribute is lazy, when the attribute is first retrieved if no
value has yet been provided.
+If a simple scalar is provided, it will be inlined as a string. Any non-code
+reference (hash, array) will result in an error - for that case instead use
+a code reference that returns the desired value.
+
Note that if your default is fired during new() there is no guarantee that
other attributes have been populated yet so you should not rely on their
existence.
If you set this to just C<1>, the predicate is automatically named
C<has_${attr_name}> if your attribute's name does not start with an
-underscore, or <_has_${attr_name_without_the_underscore}> if it does.
+underscore, or C<_has_${attr_name_without_the_underscore}> if it does.
This feature comes from L<MooseX::AttributeShortcuts>.
=item * C<builder>
probably the weakest part of Moose design-wise.
C<initializer> is not supported in core since the author considers it to be a
-bad idea but may be supported by an extension in future. Meanwhile C<trigger> or
+bad idea and Moose best practices recommend avoiding it. Meanwhile C<trigger> or
C<coerce> are more likely to be able to fulfill your needs.
There is no meta object. If you need this level of complexity you wanted
L<Devel::Dwarn> into C<main::> (via C<perl -MDevel::Dwarn ...> for example) and
using C<$obj-E<gt>$::Dwarn()> instead.
-L</default> only supports coderefs, because doing otherwise is usually a
-mistake anyway.
+L</default> only supports coderefs and plain scalars, because passing a hash
+or array reference as a default is almost always incorrect since the value is
+then shared between all objects using that default.
C<lazy_build> is not supported; you are instead encouraged to use the
C<< is => 'lazy' >> option supported by L<Moo> and L<MooseX::AttributeShortcuts>.
-C<auto_deref> is not supported since the author considers it a bad idea.
+C<auto_deref> is not supported since the author considers it a bad idea and
+it has been considered best practice to avoid it for some time.
C<documentation> will show up in a L<Moose> metaclass created from your class
but is otherwise ignored. Then again, L<Moose> ignores it as well, so this
at the end of your class to get an inlined (i.e. not horribly slow)
constructor. Moo does it automatically the first time ->new is called
-on your class.
+on your class. (C<make_immutable> is a no-op in Moo to ease migration.)
An extension L<MooX::late> exists to ease translating Moose packages
to Moo by providing a more Moose-like interface.