use B 'perlstring';
use Sub::Defer ();
-our $VERSION = '1.000004'; # 1.0.4
+our $VERSION = '1.000007'; # 1.0.7
$VERSION = eval $VERSION;
require Moo::sification;
my $target = caller;
my $class = shift;
strictures->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} = {};
+ $MAKERS{$target} = { is_class => 1 };
_install_tracked $target => extends => sub {
$class->_set_superclasses($target, @_);
$class->_maybe_reset_handlemoose($target);
sub _set_superclasses {
my $class = shift;
my $target = shift;
- for (@_) {
- _load_module($_);
- if ($INC{"Role/Tiny.pm"} && $Role::Tiny::INFO{$_}) {
+ foreach my $superclass (@_) {
+ _load_module($superclass);
+ if ($INC{"Role/Tiny.pm"} && $Role::Tiny::INFO{$superclass}) {
require Carp;
- Carp::croak("Can't extend role '$_'");
+ Carp::croak("Can't extend role '$superclass'");
}
}
# Can't do *{...} = \@_ or 5.10.0's mro.pm stops seeing @ISA
no warnings 'once'; # piss off. -- mst
$Moo::HandleMoose::MOUSE{$target} = [
grep defined, map Mouse::Util::find_meta($_), @_
- ] if $INC{"Mouse.pm"};
+ ] if Mouse::Util->can('find_meta');
}
sub _maybe_reset_handlemoose {
Unlike L<Mouse> this module does not aim at full compatibility with
L<Moose>'s surface syntax, preferring instead of provide full interoperability
-via the metaclass inflation capabilites described in L</MOO AND MOOSE>.
+via the metaclass inflation capabilities described in L</MOO AND MOOSE>.
For a full list of the minor differences between L<Moose> and L<Moo>'s surface
-syntax, see L</INCOMPATIBILITIES>.
+syntax, see L</INCOMPATIBILITIES WITH MOOSE>.
=head1 WHY MOO EXISTS
$self->$builder;
-If you set this to just C<1>, the predicate is automatically named
-C<_build_${attr_name}>. This feature comes from L<MooseX::AttributeShortcuts>.
+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}>.
+
+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>
constructor. Moo does it automatically the first time ->new is called
on your class.
+An extension L<MooX::late> exists to ease translating Moose packages
+to Moo by providing a more Moose-like interface.
+
=head1 SUPPORT
Users' IRC: #moose on irc.perl.org