Commit | Line | Data |
8f9a5c92 |
1 | #!/usr/bin/env perl |
2 | package MooseX::Role::Parameterized::Meta::Role::Parameterized; |
3 | use Moose; |
4 | extends 'Moose::Meta::Role'; |
5 | |
6 | has parameters => ( |
7 | is => 'rw', |
8 | isa => 'MooseX::Role::Parameterized::Parameters', |
9 | required => 1, |
10 | ); |
11 | |
caada7de |
12 | # we override get_method_map because this is an anonymous role, there's no |
13 | # package to check |
14 | sub get_method_map { |
15 | my $self = shift; |
16 | |
17 | return $self->{'methods'} ||= {}; |
18 | } |
19 | |
20 | # we override add_method because we don't want to install methods added through |
21 | # this API; we just stick it in the method map |
22 | sub add_method { |
23 | my ($self, $method_name, $method) = @_; |
24 | (defined $method_name && $method_name) |
25 | || Moose->throw_error("You must define a method name"); |
26 | |
27 | if (!blessed($method)) { |
28 | Moose->throw_error("You must pass a blessed method to add_method"); |
29 | } |
30 | |
31 | $self->get_method_map->{$method_name} = $method; |
32 | } |
33 | |
8f9a5c92 |
34 | __PACKAGE__->meta->make_immutable; |
00258a2d |
35 | no Moose; |
8f9a5c92 |
36 | |
37 | 1; |
38 | |