* role exclusion and aliasiing now works in composite roles too
[gitmo/Moose.git] / lib / Moose / Meta / Role / Application / ToInstance.pm
CommitLineData
fb1e11d5 1package Moose::Meta::Role::Application::ToInstance;
2
3use strict;
4use warnings;
5use metaclass;
6
7use Carp 'confess';
8use Scalar::Util 'blessed';
9
10use Data::Dumper;
11
12our $VERSION = '0.01';
13our $AUTHORITY = 'cpan:STEVAN';
14
1c9db35c 15use base 'Moose::Meta::Role::Application::ToClass';
16
17my $anon_counter = 0;
18
19sub apply {
20 my ($self, $role, $object) = @_;
21
22 # FIXME:
23 # We really should do this better, and
24 # cache the results of our efforts so
25 # that we don't need to repeat them.
26
27 my $pkg_name = __PACKAGE__ . "::__RUNTIME_ROLE_ANON_CLASS__::" . $anon_counter++;
28 eval "package " . $pkg_name . "; our \$VERSION = '0.00';";
29 die $@ if $@;
30
31 my $class = Moose::Meta::Class->initialize($pkg_name);
32 $class->superclasses(blessed($object));
33
34 bless $object => $class->name;
35
36 $self->SUPER::apply($role, $class);
37}
fb1e11d5 38
391;
40
41__END__
42
43=pod
44
45=head1 NAME
46
47Moose::Meta::Role::Application::ToInstance
48
49=head1 DESCRIPTION
50
51=head2 METHODS
52
53=over 4
54
55=item B<new>
56
57=item B<meta>
58
1c9db35c 59=item B<apply>
60
fb1e11d5 61=back
62
63=head1 BUGS
64
65All complex software has bugs lurking in it, and this module is no
66exception. If you find a bug please either email me, or add the bug
67to cpan-RT.
68
69=head1 AUTHOR
70
71Stevan Little E<lt>stevan@iinteractive.comE<gt>
72
73=head1 COPYRIGHT AND LICENSE
74
778db3ac 75Copyright 2006-2008 by Infinity Interactive, Inc.
fb1e11d5 76
77L<http://www.iinteractive.com>
78
79This library is free software; you can redistribute it and/or modify
80it under the same terms as Perl itself.
81
82=cut
83