1 package Moose::Meta::Role::Application::ToInstance;
8 use Scalar::Util 'blessed';
12 our $VERSION = '0.01';
13 our $AUTHORITY = 'cpan:STEVAN';
15 use base 'Moose::Meta::Role::Application::ToClass';
20 my ($self, $role, $object) = @_;
22 my $anon_role_key = (blessed($object) . $role->name);
25 if (exists $ANON_CLASSES{$anon_role_key} && defined $ANON_CLASSES{$anon_role_key}) {
26 $class = $ANON_CLASSES{$anon_role_key};
29 $class = Moose::Meta::Class->create_anon_class(
30 superclasses => [ blessed($object) ]
32 $ANON_CLASSES{$anon_role_key} = $class;
33 $self->SUPER::apply($role, $class);
36 $class->rebless_instance($object);
47 Moose::Meta::Role::Application::ToInstance
65 All complex software has bugs lurking in it, and this module is no
66 exception. If you find a bug please either email me, or add the bug
71 Stevan Little E<lt>stevan@iinteractive.comE<gt>
73 =head1 COPYRIGHT AND LICENSE
75 Copyright 2006-2008 by Infinity Interactive, Inc.
77 L<http://www.iinteractive.com>
79 This library is free software; you can redistribute it and/or modify
80 it under the same terms as Perl itself.