X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FMoose%2FMeta%2FRole%2FApplication%2FToInstance.pm;h=f44c0241eb30b1c8438b596c7cf922843f77f8b5;hb=d4048ef33f6cad8a3453766505ee0c67690796f6;hp=f5b64ee4e1d5e66495c7f30733eaa4695848961b;hpb=56d7c7453888ed2c684bcdb1d905841d8d03aeb1;p=gitmo%2FMoose.git diff --git a/lib/Moose/Meta/Role/Application/ToInstance.pm b/lib/Moose/Meta/Role/Application/ToInstance.pm index f5b64ee..f44c024 100644 --- a/lib/Moose/Meta/Role/Application/ToInstance.pm +++ b/lib/Moose/Meta/Role/Application/ToInstance.pm @@ -6,7 +6,7 @@ use metaclass; use Scalar::Util 'blessed'; -our $VERSION = '0.73'; +our $VERSION = '0.93'; $VERSION = eval $VERSION; our $AUTHORITY = 'cpan:STEVAN'; @@ -29,7 +29,15 @@ sub apply { $class = $ANON_CLASSES{$anon_role_key}; } else { - my $obj_meta = eval { $object->meta } || 'Moose::Meta::Class'; + my $obj_meta = Class::MOP::class_of($object) || 'Moose::Meta::Class'; + + # This is a special case to handle the case where the object's + # metaclass is a Class::MOP::Class, but _not_ a Moose::Meta::Class + # (for example, when applying a role to a Moose::Meta::Attribute + # object). + $obj_meta = 'Moose::Meta::Class' + unless $obj_meta->isa('Moose::Meta::Class'); + $class = $obj_meta->create_anon_class( superclasses => [ blessed($object) ] ); @@ -68,9 +76,7 @@ Moose::Meta::Role::Application::ToInstance - Compose a role into an instance =head1 BUGS -All complex software has bugs lurking in it, and this module is no -exception. If you find a bug please either email me, or add the bug -to cpan-RT. +See L for details on reporting bugs. =head1 AUTHOR @@ -78,7 +84,7 @@ Stevan Little Estevan@iinteractive.comE =head1 COPYRIGHT AND LICENSE -Copyright 2006-2009 by Infinity Interactive, Inc. +Copyright 2006-2010 by Infinity Interactive, Inc. L