};
*{_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);
1;
-=pod
+=head1 NAME
+
+Role::Tiny - Roles. Like a nouvelle cusine portion size slice of Moose.
=head1 SYNOPSIS
=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
Creates a new class based on base, with the roles composed into it in order.
New class is returned.
-=head1 IMPORTED METHODS
+=head1 SUBROUTINES
=head2 does_role
- if ($foo->does_role('Some::Role')) {
+ if (Role::Tiny::does_role($foo, 'Some::Role')) {
...
}
Returns true if class has been composed with role.
+This subroutine is also installed as ->does on any class a Role::Tiny is
+composed into unless that class already has an ->does method, so
+
+ if ($foo->does_role('Some::Role')) {
+ ...
+ }
+
+will work for classes but to test a role, one must use ::does_role directly
+
=head1 IMPORTED SUBROUTINES
=head2 requires