1 package Moose::Meta::Role::Application::ToInstance;
8 use Scalar::Util 'blessed';
10 our $VERSION = '0.01';
11 our $AUTHORITY = 'cpan:STEVAN';
13 use base 'Moose::Meta::Role::Application::ToClass';
18 my ($self, $role, $object) = @_;
20 my $anon_role_key = (blessed($object) . $role->name);
23 if (exists $ANON_CLASSES{$anon_role_key} && defined $ANON_CLASSES{$anon_role_key}) {
24 $class = $ANON_CLASSES{$anon_role_key};
27 $class = Moose::Meta::Class->create_anon_class(
28 superclasses => [ blessed($object) ]
30 $ANON_CLASSES{$anon_role_key} = $class;
31 $self->SUPER::apply($role, $class);
34 $class->rebless_instance($object);
45 Moose::Meta::Role::Application::ToInstance - Compose a role into an instance
63 All complex software has bugs lurking in it, and this module is no
64 exception. If you find a bug please either email me, or add the bug
69 Stevan Little E<lt>stevan@iinteractive.comE<gt>
71 =head1 COPYRIGHT AND LICENSE
73 Copyright 2006-2008 by Infinity Interactive, Inc.
75 L<http://www.iinteractive.com>
77 This library is free software; you can redistribute it and/or modify
78 it under the same terms as Perl itself.