X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FRole%2FComposite.pm;h=217ca8a48ba6961d5e350f04c18ae2b7042f0a4e;hb=a3319906531cef2b41a87138e75461ced7a3394b;hp=14b44e54207616745c2d6fede5cdd7cd15b4ee0a;hpb=b2ad68e3fbe4016e354980a636c1ed39e941162a;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Role/Composite.pm b/lib/Moose/Meta/Role/Composite.pm index 14b44e5..217ca8a 100644 --- a/lib/Moose/Meta/Role/Composite.pm +++ b/lib/Moose/Meta/Role/Composite.pm @@ -6,7 +6,7 @@ use metaclass; use Scalar::Util 'blessed'; -our $VERSION = '0.67'; +our $VERSION = '0.73_01'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -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)) { @@ -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 is a subclass of L. + =head2 METHODS =over 4 -=item B +=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 +=over 8 -=item B +=item * roles -=item B +This option is an array reference containing a list of +L object. This is a required option. -=item B +=item * name + +If a name is not given, one is generated from the roles provided. + +=back =back