use Carp 'confess';
use Devel::GlobalDestruction 'in_global_destruction';
-our $VERSION = '0.93_03';
+our $VERSION = '1.01';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
}
sub does_role {
- my ($self, $role_name) = @_;
- (defined $role_name)
+ my ($self, $role) = @_;
+ (defined $role)
|| Moose->throw_error("You must supply a role name to look for");
+ my $role_name = blessed $role ? $role->name : $role;
# if we are it,.. then return true
return 1 if $role_name eq $self->name;
# otherwise.. check our children
## ------------------------------------------------------------------
sub apply {
- my ($self, $other, @args) = @_;
+ my ($self, $other, %args) = @_;
(blessed($other))
|| Moose->throw_error("You must pass in an blessed instance");
}
Class::MOP::load_class($application_class);
- return $application_class->new(@args)->apply($self, $other);
+ return $application_class->new(%args)->apply($self, $other, \%args);
}
sub composition_class_roles { }
my (@roles, %role_params);
while (@role_specs) {
- my ($role_name, $params) = @{ splice @role_specs, 0, 1 };
- my $requested_role = Class::MOP::class_of($role_name);
+ my ($role, $params) = @{ splice @role_specs, 0, 1 };
+ my $requested_role
+ = blessed $role
+ ? $role
+ : Class::MOP::class_of($role);
my $actual_role = $requested_role->_role_for_combination($params);
push @roles => $actual_role;
=item B<< Moose::Meta::Role->combine( [ $role => { ... } ], [ $role ], ... ) >>
This method accepts a list of array references. Each array reference
-should contain a role name as its first element. The second element is
+should contain a role name or L<Moose::Meta::Role> object as its first element. The second element is
an optional hash reference. The hash reference can contain C<-excludes>
and C<-alias> keys to control how methods are composed from the role.
This returns a I<unique> list of all roles that this role does, and
all the roles that its roles do.
-=item B<< $metarole->does_role($role_name) >>
+=item B<< $metarole->does_role($role) >>
-Given a role I<name>, returns true if this role does the given
-role.
+Given a role I<name> or L<Moose::Meta::Role> object, returns true if this role
+does the given role.
=item B<< $metarole->add_role($role) >>
=head2 Method modifiers
-These methods act like their counterparts in L<Class::Mop::Class> and
+These methods act like their counterparts in L<Class::MOP::Class> and
L<Moose::Meta::Class>.
However, method modifiers are simply stored internally, and are not