use Scalar::Util 'blessed';
use Carp 'confess';
+use Sub::Name 'subname';
+use Devel::GlobalDestruction 'in_global_destruction';
-our $VERSION = '0.75_01';
+our $VERSION = '0.77';
$VERSION = eval $VERSION;
our $AUTHORITY = 'cpan:STEVAN';
my $full_method_name = ($self->name . '::' . $method_name);
$self->add_package_symbol(
{ sigil => '&', type => 'CODE', name => $method_name },
- Class::MOP::subname($full_method_name => $body)
+ subname($full_method_name => $body)
);
$self->update_package_cache_flag; # still valid, since we just added the method to the map, and if it was invalid before that then get_method_map updated it
my (@roles, %role_params);
while (@role_specs) {
- my ($role, $params) = @{ splice @role_specs, 0, 1 };
- push @roles => Class::MOP::class_of($role);
+ my ($role_name, $params) = @{ splice @role_specs, 0, 1 };
+ my $requested_role = Class::MOP::class_of($role_name);
+
+ my $actual_role = $requested_role->role_for_combination($params);
+ push @roles => $actual_role;
+
next unless defined $params;
- $role_params{$role} = $params;
+ $role_params{$actual_role->name} = $params;
}
my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
return $c;
}
+sub role_for_combination {
+ my ($self, $params) = @_;
+ return $self;
+}
+
sub create {
my ( $role, $package_name, %options ) = @_;
sub DESTROY {
my $self = shift;
- return if Class::MOP::in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
+ return if in_global_destruction(); # it'll happen soon anyway and this just makes things more complicated
no warnings 'uninitialized';
return unless $self->name =~ /^$ANON_ROLE_PREFIX/;
The return value is a new L<Moose::Meta::Role::Composite> that
represents the combined roles.
+=item B<< Moose::Meta::Role->role_for_combination($options) >>
+
+This is a hook for incorporating role-combination parameters. This
+method returns a role meta-object (by default the invocant role) to be
+used for the combination.
+
=item B<< Moose::Meta::Role->create($name, %options) >>
This method is identical to the L<Moose::Meta::Class> C<create>