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'" }
54 sub requires { confess "Mouse::Role does not currently support 'requires'" }
56 sub excludes { confess "Mouse::Role does not currently support 'excludes'" }
63 my $meta = Mouse::Meta::Role->initialize(caller);
66 no warnings 'redefine';
67 *{$caller.'::meta'} = sub { $meta };
69 Mouse::Role->export_to_level(1, @_);
76 for my $keyword (@EXPORT) {
77 delete ${ $caller . '::' }{$keyword};
91 =head2 meta -> Mouse::Meta::Role
93 Returns this role's metaclass instance.
95 =head2 before (method|methods) => Code
97 Sets up a "before" method modifier. See L<Moose/before> or
98 L<Class::Method::Modifiers/before>.
100 =head2 after (method|methods) => Code
102 Sets up an "after" method modifier. See L<Moose/after> or
103 L<Class::Method::Modifiers/after>.
105 =head2 around (method|methods) => Code
107 Sets up an "around" method modifier. See L<Moose/around> or
108 L<Class::Method::Modifiers/around>.
110 =head2 has (name|names) => parameters
112 Sets up an attribute (or if passed an arrayref of names, multiple attributes) to
113 this role. See L<Mouse/has>.
115 =head2 confess error -> BOOM
117 L<Carp/confess> for your convenience.
119 =head2 blessed value -> ClassName | undef
121 L<Scalar::Util/blessed> for your convenience.
127 Importing Mouse::Role will give you sugar.
131 Please unimport Mouse (C<no Mouse::Role>) so that if someone calls one of the
132 keywords (such as L</has>) it will break loudly instead breaking subtly.