*{_getglob("${target}::with")} = sub {
require Moo::Role;
die "Only one role supported at a time by with" if @_ > 1;
- Moo::Role->apply_role_to_package($_[0], $target);
+ Moo::Role->apply_role_to_package($target, $_[0]);
};
$MAKERS{$target} = {};
*{_getglob("${target}::has")} = sub {
}
sub apply_role_to_package {
- my ($me, $role, $to) = @_;
- $me->SUPER::apply_role_to_package($role, $to);
+ my ($me, $to, $role) = @_;
+ $me->SUPER::apply_role_to_package($to, $role);
$me->_handle_constructor($to, $INFO{$role}{attributes});
}
};
*{_getglob "${target}::with"} = sub {
die "Only one role supported at a time by with" if @_ > 1;
- $me->apply_role_to_package($_[0], $target);
+ $me->apply_role_to_package($target, $_[0]);
};
# grab all *non-constant* (ref eq 'SCALAR') subs present
# in the symbol table and store their refaddrs (no need to forcibly
}
sub apply_role_to_package {
- my ($me, $role, $to) = @_;
+ my ($me, $to, $role) = @_;
_load_module($role);
=head2 apply_role_to_package
- Role::Tiny->apply_role_to_package('Some::Role', 'Some::Package');
+ Role::Tiny->apply_role_to_package('Some::Package', 'Some::Role');
Composes role with package
sub try_apply_to {
my $to = shift;
- exception { Role::Tiny->apply_role_to_package('MyRole', $to) }
+ exception { Role::Tiny->apply_role_to_package($to, 'MyRole') }
}
is(try_apply_to('MyClass'), undef, 'role applies cleanly');