bump version to 0.88
[gitmo/Moose.git] / lib / Moose / Meta / Role / Composite.pm
index 94e54c8..c7c5d45 100644 (file)
@@ -6,24 +6,24 @@ use metaclass;
 
 use Scalar::Util 'blessed';
 
-our $VERSION   = '0.59';
+our $VERSION   = '0.88';
 $VERSION = eval $VERSION;
 our $AUTHORITY = 'cpan:STEVAN';
 
 use base 'Moose::Meta::Role';
 
 # NOTE:
-# we need to override the ->name 
+# we need to override the ->name
 # method from Class::MOP::Package
-# since we don't have an actual 
+# since we don't have an actual
 # package for this.
 # - SL
 __PACKAGE__->meta->add_attribute('name' => (reader => 'name'));
 
 # NOTE:
-# Again, since we don't have a real 
-# package to store our methods in, 
-# we use a HASH ref instead. 
+# Again, since we don't have a real
+# package to store our methods in,
+# we use a HASH ref instead.
 # - SL
 __PACKAGE__->meta->add_attribute('methods' => (
     reader  => 'get_method_map',
@@ -33,9 +33,12 @@ __PACKAGE__->meta->add_attribute('methods' => (
 sub new {
     my ($class, %params) = @_;
     # the roles param is required ...
-    ($_->isa('Moose::Meta::Role'))
-        || Moose->throw_error("The list of roles must be instances of Moose::Meta::Role, not $_")
-            foreach @{$params{roles}};
+    foreach ( @{$params{roles}} ) {
+        unless ( $_->isa('Moose::Meta::Role') ) {
+            require Moose;
+            Moose->throw_error("The list of roles must be instances of Moose::Meta::Role, not $_");
+        }
+    }
     # and the name is created from the
     # roles if one has not been provided
     $params{name} ||= (join "|" => map { $_->name } @{$params{roles}});
@@ -48,8 +51,10 @@ sub new {
 # add the symbol.
 sub add_method {
     my ($self, $method_name, $method) = @_;
-    (defined $method_name && $method_name)
-    || Moose->throw_error("You must define a method name");
+
+    unless ( defined $method_name && $method_name ) {
+        Moose->throw_error("You must define a method name");
+    }
 
     my $body;
     if (blessed($method)) {
@@ -57,7 +62,7 @@ sub add_method {
         if ($method->package_name ne $self->name) {
             $method = $method->clone(
                 package_name => $self->name,
-                name         => $method_name            
+                name         => $method_name
             ) if $method->can('clone');
         }
     }
@@ -81,19 +86,36 @@ Moose::Meta::Role::Composite - An object to represent the set of roles
 
 =head1 DESCRIPTION
 
+A composite is a role that consists of a set of two or more roles.
+
+The API of a composite role is almost identical to that of a regular
+role.
+
+=head1 INHERITANCE
+
+C<Moose::Meta::Role::Composite> is a subclass of L<Moose::Meta::Role>.
+
 =head2 METHODS
 
 =over 4
 
-=item B<new>
+=item B<< Moose::Meta::Role::Composite->new(%options) >>
+
+This returns a new composite role object. It accepts the same
+options as its parent class, with a few changes:
 
-=item B<meta>
+=over 8
 
-=item B<name>
+=item * roles
 
-=item B<get_method_map>
+This option is an array reference containing a list of
+L<Moose::Meta::Role> object. This is a required option.
 
-=item B<add_method>
+=item * name
+
+If a name is not given, one is generated from the roles provided.
+
+=back
 
 =back
 
@@ -109,7 +131,7 @@ Stevan Little E<lt>stevan@iinteractive.comE<gt>
 
 =head1 COPYRIGHT AND LICENSE
 
-Copyright 2006-2008 by Infinity Interactive, Inc.
+Copyright 2006-2009 by Infinity Interactive, Inc.
 
 L<http://www.iinteractive.com>