2 package Moose::Meta::Role;
10 our $VERSION = '0.01';
12 __PACKAGE__->meta->add_attribute('role_meta' => (
16 __PACKAGE__->meta->add_attribute('attribute_map' => (
17 reader => 'get_attribute_map',
21 __PACKAGE__->meta->add_attribute('method_modifier_map' => (
22 reader => 'get_method_modifier_map',
37 $options{role_meta} = Class::MOP::Class->initialize($options{role_name});
38 my $self = $class->meta->new_object(%options);
43 # we delegate to some role_meta methods for convience here
44 # the Moose::Meta::Role is meant to be a read-only interface
45 # to the underlying role package, if you want to manipulate
46 # that, just use ->role_meta
48 sub name { (shift)->role_meta->name }
49 sub version { (shift)->role_meta->version }
51 sub get_method { (shift)->role_meta->get_method(@_) }
52 sub has_method { (shift)->role_meta->has_method(@_) }
55 # meta is not applicable in this context,
56 # if you want to see it use the ->role_meta
57 grep { !/^meta$/ } $self->role_meta->get_method_list;
60 # ... however the items in statis (attributes & method modifiers)
61 # can be removed and added to through this API
66 my ($self, $name, %attr_desc) = @_;
67 $self->get_attribute_map->{$name} = \%attr_desc;
71 my ($self, $name) = @_;
72 exists $self->get_attribute_map->{$name} ? 1 : 0;
76 my ($self, $name) = @_;
77 $self->get_attribute_map->{$name}
80 sub remove_attribute {
81 my ($self, $name) = @_;
82 delete $self->get_attribute_map->{$name}
85 sub get_attribute_list {
87 keys %{$self->get_attribute_map};
92 sub add_method_modifier {
93 my ($self, $modifier_type, $method_name, $method) = @_;
94 $self->get_method_modifier_map->{$modifier_type}->{$method_name} = $method;
97 sub has_method_modifier {
98 my ($self, $modifier_type, $method_name) = @_;
99 exists $self->get_method_modifier_map->{$modifier_type}->{$method_name} ? 1 : 0
102 sub get_method_modifier {
103 my ($self, $modifier_type, $method_name) = @_;
104 $self->get_method_modifier_map->{$modifier_type}->{$method_name};
107 sub remove_method_modifier {
108 my ($self, $modifier_type, $method_name) = @_;
109 delete $self->get_method_modifier_map->{$modifier_type}->{$method_name};
112 sub get_method_modifier_list {
113 my ($self, $modifier_type) = @_;
114 keys %{$self->get_method_modifier_map->{$modifier_type}};
126 Moose::Meta::Role - The Moose Role metaclass
156 =item B<get_method_list>
162 =item B<add_attribute>
164 =item B<has_attribute>
166 =item B<get_attribute>
168 =item B<get_attribute_list>
170 =item B<get_attribute_map>
172 =item B<remove_attribute>
178 =item B<add_method_modifier>
180 =item B<get_method_modifier>
182 =item B<has_method_modifier>
184 =item B<get_method_modifier_list>
186 =item B<get_method_modifier_map>
188 =item B<remove_method_modifier>
194 All complex software has bugs lurking in it, and this module is no
195 exception. If you find a bug please either email me, or add the bug
200 Stevan Little E<lt>stevan@iinteractive.comE<gt>
202 =head1 COPYRIGHT AND LICENSE
204 Copyright 2006 by Infinity Interactive, Inc.
206 L<http://www.iinteractive.com>
208 This library is free software; you can redistribute it and/or modify
209 it under the same terms as Perl itself.