1 package Reaction::Role;
4 use Reaction::ClassExporter;
6 use Moose::Meta::Class;
8 #TODO: review for Reaction::Object switch / Reaction::Meta::Class
10 use namespace::clean -except => [ qw(meta) ];
12 override exports_for_package => sub {
13 my ($self, $package) = @_;
14 my %exports = $self->SUPER::exports_for_package($package);
15 delete $exports{class};
16 $exports{role} = sub { $self->do_role_sub($package, @_); };
20 override next_import_package => sub { 'Moose::Role' };
22 override default_base => sub { () };
24 override add_method_to_target => sub {
25 my ($self, $target, $method) = @_;
26 $target->meta->add_method(@$method);
28 override next_import => sub {
33 push @_, '-metaclass' => 'Reaction::Meta::Role';
38 my ($self, $package, $role, $which, $setup) = @_;
39 confess "Invalid role declaration, should be: role Role which { ... }"
40 unless ($which eq 'which' && ref($setup) eq 'CODE');
41 $self->setup_and_cleanup($role, $setup);
44 __PACKAGE__->meta->make_immutable;
61 See L<Reaction::Class> for authors.
65 See L<Reaction::Class> for the license.