Commit | Line | Data |
faa0f968 |
1 | |
2 | package Moose::Meta::Role::Method::Required; |
3 | |
4 | use strict; |
5 | use warnings; |
2cf88ade |
6 | use metaclass; |
7 | |
8 | use overload '""' => sub { shift->name }, # stringify to method name |
9 | fallback => 1; |
10 | |
11 | use base qw(Class::MOP::Object); |
faa0f968 |
12 | |
2cf88ade |
13 | # This is not a Moose::Meta::Role::Method because it has no implementation, it |
14 | # is just a name |
15 | |
2ee514b1 |
16 | __PACKAGE__->meta->add_attribute('name' => ( |
17 | reader => 'name', |
18 | required => 1, |
dc2b7cc8 |
19 | Class::MOP::_definition_context(), |
2ee514b1 |
20 | )); |
d67145ed |
21 | |
bc336e8e |
22 | sub new { shift->_new(@_) } |
23 | |
faa0f968 |
24 | 1; |
25 | |
ad46f524 |
26 | # ABSTRACT: A Moose metaclass for required methods in Roles |
27 | |
faa0f968 |
28 | __END__ |
29 | |
30 | =pod |
31 | |
faa0f968 |
32 | =head1 DESCRIPTION |
33 | |
d7a5a659 |
34 | =head1 INHERITANCE |
35 | |
36 | C<Moose::Meta::Role::Method::Required> is a subclass of L<Class::MOP::Object>. |
37 | It is B<not> a subclass of C<Moose::Meta::Role::Method> since it does not |
38 | provide an implementation of the method. |
39 | |
40 | =head1 METHODS |
41 | |
42 | =over 4 |
43 | |
44 | =item B<< Moose::Meta::Role::Method::Required->new(%options) >> |
45 | |
46 | This creates a new type constraint based on the provided C<%options>: |
47 | |
48 | =over 8 |
49 | |
50 | =item * name |
51 | |
52 | The method name. This is required. |
53 | |
54 | =back |
55 | |
56 | =item B<< $method->name >> |
57 | |
58 | Returns the required method's name, as provided to the constructor. |
59 | |
60 | =back |
61 | |
faa0f968 |
62 | =head1 BUGS |
63 | |
d4048ef3 |
64 | See L<Moose/BUGS> for details on reporting bugs. |
faa0f968 |
65 | |
07b0f1a5 |
66 | =cut |