1 package Moose::Meta::Role::Composite;
8 use Scalar::Util 'blessed';
10 our $VERSION = '0.55_01';
11 $VERSION = eval $VERSION;
12 our $AUTHORITY = 'cpan:STEVAN';
14 use base 'Moose::Meta::Role';
17 # we need to override the ->name
18 # method from Class::MOP::Package
19 # since we don't have an actual
22 __PACKAGE__->meta->add_attribute('name' => (reader => 'name'));
25 # Again, since we don't have a real
26 # package to store our methods in,
27 # we use a HASH ref instead.
29 __PACKAGE__->meta->add_attribute('methods' => (
30 reader => 'get_method_map',
35 my ($class, %params) = @_;
36 # the roles param is required ...
37 ($_->isa('Moose::Meta::Role'))
38 || confess "The list of roles must be instances of Moose::Meta::Role, not $_"
39 foreach @{$params{roles}};
40 # and the name is created from the
41 # roles if one has not been provided
42 $params{name} ||= (join "|" => map { $_->name } @{$params{roles}});
43 $class->_new(\%params);
47 # we need to override this cause
48 # we dont have that package I was
49 # talking about above.
52 my ($self, $method_name, $method) = @_;
53 (defined $method_name && $method_name)
54 || confess "You must define a method name";
56 # make sure to bless the
58 $method = $self->method_metaclass->wrap(
60 package_name => $self->name,
62 ) if !blessed($method);
64 $self->get_method_map->{$method_name} = $method;
75 Moose::Meta::Role::Composite - An object to represent the set of roles
89 =item B<get_method_map>
97 All complex software has bugs lurking in it, and this module is no
98 exception. If you find a bug please either email me, or add the bug
103 Stevan Little E<lt>stevan@iinteractive.comE<gt>
105 =head1 COPYRIGHT AND LICENSE
107 Copyright 2006-2008 by Infinity Interactive, Inc.
109 L<http://www.iinteractive.com>
111 This library is free software; you can redistribute it and/or modify
112 it under the same terms as Perl itself.