1 package Moose::Meta::Role::Application::ToMetaclassInstance;
7 use Scalar::Util 'blessed';
9 our $VERSION = '0.55_03';
10 $VERSION = eval $VERSION;
11 our $AUTHORITY = 'cpan:STEVAN';
13 use base 'Moose::Meta::Role::Application::ToClass';
15 __PACKAGE__->meta->add_attribute('rebless_params' => (
16 reader => 'rebless_params',
23 my ( $self, $role, $meta ) = @_;
25 my $anon_role_key = (blessed($meta) . $role->name);
28 if (exists $ANON_CLASSES{$anon_role_key} && defined $ANON_CLASSES{$anon_role_key}) {
29 $class = $ANON_CLASSES{$anon_role_key};
33 = ( ref $meta )->can('create_anon_class')
35 : 'Moose::Meta::Class';
36 $class = $metaclass_class->create_anon_class(
37 superclasses => [ blessed($meta) ],
40 $ANON_CLASSES{$anon_role_key} = $class;
41 $self->SUPER::apply( $role, $class );
44 $class->rebless_instance( $meta, %{ $self->rebless_params } );
55 Moose::Meta::Role::Application::ToMetaclassInstance - Compose a role into a metaclass instance
69 =item B<rebless_params>
75 All complex software has bugs lurking in it, and this module is no
76 exception. If you find a bug please either email me, or add the bug
81 Stevan Little E<lt>stevan@iinteractive.comE<gt>
83 =head1 COPYRIGHT AND LICENSE
85 Copyright 2006-2008 by Infinity Interactive, Inc.
87 L<http://www.iinteractive.com>
89 This library is free software; you can redistribute it and/or modify
90 it under the same terms as Perl itself.