X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FRole.pm;h=402ed6db00ce05e689a67e033dc42b15686cb1af;hb=c179d548a2336b7030c1801d44d1d26663d20676;hp=0da0ebcaa25d38053c3f40c9cf5025bc2f22d7c3;hpb=9e4ed568f2e5c1041e6fea8d0cbde420562ab5df;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Role.pm b/lib/Moose/Meta/Role.pm index 0da0ebc..402ed6d 100644 --- a/lib/Moose/Meta/Role.pm +++ b/lib/Moose/Meta/Role.pm @@ -10,7 +10,7 @@ use Carp 'confess'; use Sub::Name 'subname'; use Devel::GlobalDestruction 'in_global_destruction'; -our $VERSION = '0.84'; +our $VERSION = '0.87'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -142,6 +142,24 @@ $META->add_attribute( default => 'Moose::Meta::Role::Method::Conflicting', ); +$META->add_attribute( + 'application_to_class_class', + reader => 'application_to_class_class', + default => 'Moose::Meta::Role::Application::ToClass', +); + +$META->add_attribute( + 'application_to_role_class', + reader => 'application_to_role_class', + default => 'Moose::Meta::Role::Application::ToRole', +); + +$META->add_attribute( + 'application_to_instance_class', + reader => 'application_to_instance_class', + default => 'Moose::Meta::Role::Application::ToInstance', +); + ## some things don't always fit, so they go here ... sub add_attribute { @@ -478,18 +496,19 @@ sub apply { (blessed($other)) || Moose->throw_error("You must pass in an blessed instance"); + my $application_class; if ($other->isa('Moose::Meta::Role')) { - require Moose::Meta::Role::Application::ToRole; - return Moose::Meta::Role::Application::ToRole->new(@args)->apply($self, $other); + $application_class = $self->application_to_role_class; } elsif ($other->isa('Moose::Meta::Class')) { - require Moose::Meta::Role::Application::ToClass; - return Moose::Meta::Role::Application::ToClass->new(@args)->apply($self, $other); + $application_class = $self->application_to_class_class; } else { - require Moose::Meta::Role::Application::ToInstance; - return Moose::Meta::Role::Application::ToInstance->new(@args)->apply($self, $other); + $application_class = $self->application_to_instance_class; } + + Class::MOP::load_class($application_class); + return $application_class->new(@args)->apply($self, $other); } sub combine { @@ -793,7 +812,7 @@ This method creates a new role object with the provided name. This method accepts a list of array references. Each array reference should contain a role name as its first element. The second element is -an optional hash reference. The hash reference can contain C +an optional hash reference. The hash reference can contain C and C keys to control how methods are composed from the role. The return value is a new L that