sub combine {
my ($class, @role_specs) = @_;
- require Moose::Meta::Role::Application::RoleSummation;
require Moose::Meta::Role::Composite;
my (@roles, %role_params);
}
my $c = Moose::Meta::Role::Composite->new(roles => \@roles);
- Moose::Meta::Role::Application::RoleSummation->new(
- role_params => \%role_params
- )->apply($c);
-
- return $c;
+ return $c->apply_params(\%role_params);
}
sub _role_for_combination {
default => sub { {} }
));
+__PACKAGE__->meta->add_attribute(
+ 'application_role_summation_class',
+ reader => 'application_role_summation_class',
+ default => 'Moose::Meta::Role::Application::RoleSummation',
+);
+
sub new {
my ($class, %params) = @_;
# the roles param is required ...
$self->get_method_map->{$method_name} = $method;
}
+sub apply_params {
+ my ($self, $role_params) = @_;
+ Class::MOP::load_class($self->application_role_summation_class);
+
+ $self->application_role_summation_class->new(
+ role_params => $role_params,
+ )->apply($self);
+
+ return $self;
+}
+
1;
__END__
If a name is not given, one is generated from the roles provided.
+=item * apply_params(\%role_params)
+
+Creates a new RoleSummation role application with C<%role_params> and applies
+the composite role to it. The RoleSummation role application class used is
+determined by the composite role's C<application_role_summation_class>
+attribute.
+
=back
=back