X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMouse%2FMeta%2FRole%2FComposite.pm;h=e8244dbf2c8e11351386c7089208a04e369f3c5d;hb=95637edb1de318b764f8ec2fc8b5c5c8d4430010;hp=b05f9173b0c54a183ff1ab40ce5ff9beddae3cbc;hpb=43c1bb1ad8ebe5534248ddc761a9bbbc95044643;p=gitmo%2FMouse.git diff --git a/lib/Mouse/Meta/Role/Composite.pm b/lib/Mouse/Meta/Role/Composite.pm index b05f917..e8244db 100644 --- a/lib/Mouse/Meta/Role/Composite.pm +++ b/lib/Mouse/Meta/Role/Composite.pm @@ -4,6 +4,25 @@ use Mouse::Meta::Role; use Mouse::Meta::Role::Application; our @ISA = qw(Mouse::Meta::Role); +# FIXME: Mouse::Meta::Role::Composite does things in different way from Moose's +# Moose: creates a new class for the consumer, and applies roles to it. +# Mouse: creates a coposite role and apply roles to the role, +# and then applies it to the consumer. + +sub new { + my $class = shift; + my $args = $class->Mouse::Object::BUILDARGS(@_); + my $roles = delete $args->{roles}; + my $self = $class->create_anon_role(%{$args}); + foreach my $role_spec(@{$roles}) { + my($role, $args) = ref($role_spec) eq 'ARRAY' + ? @{$role_spec} + : ($role_spec, {}); + $role->apply($self, %{$args}); + } + return $self; +} + sub get_method_list { my($self) = @_; return keys %{ $self->{methods} }; @@ -137,7 +156,7 @@ Mouse::Meta::Role::Composite - An object to represent the set of roles =head1 VERSION -This document describes Mouse version 0.71 +This document describes Mouse version 0.90 =head1 SEE ALSO