8 use Mouse::Util 'blessed';
10 use Mouse::Meta::Role;
12 our @EXPORT = qw(before after around has extends with requires excludes confess blessed);
15 my $meta = Mouse::Meta::Role->initialize(caller);
19 $meta->add_before_method_modifier($_ => $code);
24 my $meta = Mouse::Meta::Role->initialize(caller);
28 $meta->add_after_method_modifier($_ => $code);
33 my $meta = Mouse::Meta::Role->initialize(caller);
37 $meta->add_around_method_modifier($_ => $code);
42 my $meta = Mouse::Meta::Role->initialize(caller);
47 $meta->add_attribute($name => \%opts);
50 sub extends { confess "Roles do not support 'extends'" }
52 sub with { confess "Mouse::Role does not currently support 'with'" }
55 my $meta = Mouse::Meta::Role->initialize(caller);
56 Carp::croak "Must specify at least one method" unless @_;
57 $meta->add_required_methods(@_);
60 sub excludes { confess "Mouse::Role does not currently support 'excludes'" }
67 my $meta = Mouse::Meta::Role->initialize(caller);
70 no warnings 'redefine';
71 *{$caller.'::meta'} = sub { $meta };
73 Mouse::Role->export_to_level(1, @_);
80 for my $keyword (@EXPORT) {
81 delete ${ $caller . '::' }{$keyword};
95 =head2 meta -> Mouse::Meta::Role
97 Returns this role's metaclass instance.
99 =head2 before (method|methods) => Code
101 Sets up a "before" method modifier. See L<Moose/before> or
102 L<Class::Method::Modifiers/before>.
104 =head2 after (method|methods) => Code
106 Sets up an "after" method modifier. See L<Moose/after> or
107 L<Class::Method::Modifiers/after>.
109 =head2 around (method|methods) => Code
111 Sets up an "around" method modifier. See L<Moose/around> or
112 L<Class::Method::Modifiers/around>.
114 =head2 has (name|names) => parameters
116 Sets up an attribute (or if passed an arrayref of names, multiple attributes) to
117 this role. See L<Mouse/has>.
119 =head2 confess error -> BOOM
121 L<Carp/confess> for your convenience.
123 =head2 blessed value -> ClassName | undef
125 L<Scalar::Util/blessed> for your convenience.
131 Importing Mouse::Role will give you sugar.
135 Please unimport Mouse (C<no Mouse::Role>) so that if someone calls one of the
136 keywords (such as L</has>) it will break loudly instead breaking subtly.