Method::Required->name is required
[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 $VERSION   = '0.79';
14 $VERSION = eval $VERSION;
15 our $AUTHORITY = 'cpan:STEVAN';
16
17 # This is not a Moose::Meta::Role::Method because it has no implementation, it
18 # is just a name
19
20 __PACKAGE__->meta->add_attribute('name' => (
21     reader   => 'name',
22     required => 1,
23 ));
24
25 sub new { shift->_new(@_) }
26
27 sub is_conflict { 0 }
28
29 1;
30
31 __END__
32
33 =pod
34
35 =head1 NAME
36
37 Moose::Meta::Role::Method::Required - A Moose metaclass for required methods in Roles
38
39 =head1 DESCRIPTION
40
41 =head1 INHERITANCE
42
43 C<Moose::Meta::Role::Method::Required> is a subclass of L<Class::MOP::Object>.
44 It is B<not> a subclass of C<Moose::Meta::Role::Method> since it does not
45 provide an implementation of the method.
46
47 =head1 METHODS
48
49 =over 4
50
51 =item B<< Moose::Meta::Role::Method::Required->new(%options) >>
52
53 This creates a new type constraint based on the provided C<%options>:
54
55 =over 8
56
57 =item * name
58
59 The method name. This is required.
60
61 =back
62
63 =item B<< $method->name >>
64
65 Returns the required method's name, as provided to the constructor.
66
67 =item B<< $method->is_conflict >>
68
69 Returns whether the method requirement is due to a conflict. By default for
70 this class, it's false.
71
72 =back
73
74 =head1 BUGS
75
76 All complex software has bugs lurking in it, and this module is no
77 exception. If you find a bug please either email me, or add the bug
78 to cpan-RT.
79
80 =head1 AUTHOR
81
82 Stevan Little E<lt>stevan@iinteractive.comE<gt>
83
84 =head1 COPYRIGHT AND LICENSE
85
86 Copyright 2006-2009 by Infinity Interactive, Inc.
87
88 L<http://www.iinteractive.com>
89
90 This library is free software; you can redistribute it and/or modify
91 it under the same terms as Perl itself.
92
93 =cut