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