1 package Moose::Meta::Role::Application::ToMetaclassInstance;
7 use Scalar::Util 'blessed';
10 our $AUTHORITY = 'cpan:STEVAN';
12 use base 'Moose::Meta::Role::Application::ToClass';
14 __PACKAGE__->meta->add_attribute('rebless_params' => (
15 reader => 'rebless_params',
22 my ( $self, $role, $meta ) = @_;
24 my $anon_role_key = (blessed($meta) . $role->name);
27 if (exists $ANON_CLASSES{$anon_role_key} && defined $ANON_CLASSES{$anon_role_key}) {
28 $class = $ANON_CLASSES{$anon_role_key};
32 = ( ref $meta )->can('create_anon_class')
34 : 'Moose::Meta::Class';
35 $class = $metaclass_class->create_anon_class(
36 superclasses => [ blessed($meta) ],
39 $ANON_CLASSES{$anon_role_key} = $class;
40 $self->SUPER::apply( $role, $class );
43 $class->rebless_instance( $meta, %{ $self->rebless_params } );
54 Moose::Meta::Role::Application::ToMetaclassInstance - Compose a role into a metaclass instance
68 =item B<rebless_params>
74 All complex software has bugs lurking in it, and this module is no
75 exception. If you find a bug please either email me, or add the bug
80 Stevan Little E<lt>stevan@iinteractive.comE<gt>
82 =head1 COPYRIGHT AND LICENSE
84 Copyright 2006-2008 by Infinity Interactive, Inc.
86 L<http://www.iinteractive.com>
88 This library is free software; you can redistribute it and/or modify
89 it under the same terms as Perl itself.