clean up and add NAME sections
[gitmo/Moo.git] / lib / Role / Tiny.pm
index 93d2a7f..57028ed 100644 (file)
@@ -35,7 +35,7 @@ sub import {
   };
   *{_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
@@ -49,7 +49,7 @@ sub import {
 }
 
 sub apply_role_to_package {
-  my ($me, $role, $to) = @_;
+  my ($me, $to, $role) = @_;
 
   _load_module($role);
 
@@ -222,7 +222,9 @@ sub does_role {
 
 1;
 
-=pod
+=head1 NAME
+
+Role::Tiny - Roles. Like a nouvelle cusine portion size slice of Moose.
 
 =head1 SYNOPSIS
 
@@ -279,7 +281,7 @@ is to be much simpler, hence disallowing composition of multiple roles at once.
 
 =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
 
@@ -297,16 +299,25 @@ resulting class.
 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