+ - Re-export on 'use Moo' after 'no Moo'
+ - Export meta() into roles (but mark as non-method to avoid composing it)
- Don't generate an accessor for rw attributes if reader+writer both set
- Support builder => sub {} ala MooseX::AttributeShortcuts
- Fix 'no Moo;' to preserve non-sub package variables
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);
return;
};
}
+ return if $MAKERS{$target}{is_class}; # already exported into this package
+ $MAKERS{$target}{is_class} = 1;
{
no strict 'refs';
@{"${target}::ISA"} = do {
goto &Role::Tiny::does_role;
}
+# duplicated in Moo::Role
sub meta {
require Moo::HandleMoose::FakeMetaClass;
my $class = ref($_[0])||$_[0];
if ($Moo::MAKERS{$target} and $Moo::MAKERS{$target}{is_class}) {
die "Cannot import Moo::Role into a Moo class";
}
- return if $INFO{$target}; # already exported into this package
- $INFO{$target} = { is_role => 1 };
+ $INFO{$target} ||= {};
# get symbol table reference
my $stash = do { no strict 'refs'; \%{"${target}::"} };
_install_tracked $target => has => sub {
$me->apply_roles_to_package($target, @_);
$me->_maybe_reset_handlemoose($target);
};
+ return if $INFO{$target}{is_role}; # already exported into this package
+ $INFO{$target}{is_role} = 1;
+ *{_getglob("${target}::meta")} = $me->can('meta');
# grab all *non-constant* (stash slot is not a scalarref) subs present
# in the symbol table and store their refaddrs (no need to forcibly
# inflate constant subs into real subs) - also add '' to here (this
}
}
+# duplicate from Moo::Object
+sub meta {
+ require Moo::HandleMoose::FakeMetaClass;
+ my $class = ref($_[0])||$_[0];
+ bless({ name => $class }, 'Moo::HandleMoose::FakeMetaClass');
+}
+
sub unimport {
my $target = caller;
_unimport_coderefs($target, $INFO{$target});
ok eval q{
package Roller;
- use Moo;
+ use Moo::Role;
has foo => ( is => 'ro' );
- no Moo;
+ no Moo::Role;
- use Moo;
+ use Moo::Role;
has foo2 => ( is => 'ro' );
- no Moo;
+ no Moo::Role;
1;
}, "subs imported on 'use Moo::Role;' after 'no Moo::Role;'"