foo
[gitmo/Moose.git] / lib / Moose / Compiler / Moose.pm
CommitLineData
4276ccb4 1
2package Moose::Compiler::Moose;
3use Moose;
4
5our $VERSION = '0.01';
6
7with 'Moose::Compiler::Engine';
8
9sub compile_class {
10 my ($self, $meta) = @_;
11 my $o = '';
12 $o .= ('package ' . $meta->name . ";\n");
13 $o .= ("use Moose;\n");
14 $o .= ("\n");
15 $o .= ("our \$VERSION = '" . $meta->version . "';\n");
16 $o .= ("\n");
17 foreach my $attr_name ($meta->get_attribute_list) {
18 my $attr = $meta->get_attribute($attr_name);
19 my @options;
20 push @options => ("is => '" . $attr->_is_metadata . "'")
21 if $attr->_is_metadata;
22 push @options => ("isa => '" . $attr->_isa_metadata . "'")
23 if $attr->_isa_metadata;
24 push @options => ("does => '" . $attr->_does_metadata . "'")
25 if $attr->_does_metadata;
26 $o .= ("has '" . $attr->name . "' => (" . (join ", " => @options) . ");\n");
27 }
28 $o .= ("\n");
29 $o .= ("1;\n");
30 $o .= ("\n");
31 $o .= ("__END__\n");
32 return $o;
33}
34
351;
36
37__END__
38
39=pod
40
41=head1 NAME
42
43Moose::Compiler::Moose - A Moose compiler engine for compiling to Moose
44
45=head1 DESCRIPTION
46
47=head1 METHODS
48
49=over 4
50
51=item B<meta>
52
53This will return the metaclass associated with the given role.
54
55=item B<compile_class>
56
57=back
58
59=head1 BUGS
60
61All complex software has bugs lurking in it, and this module is no
62exception. If you find a bug please either email me, or add the bug
63to cpan-RT.
64
65=head1 AUTHOR
66
67Stevan Little E<lt>stevan@iinteractive.comE<gt>
68
69=head1 COPYRIGHT AND LICENSE
70
71Copyright 2006 by Infinity Interactive, Inc.
72
73L<http://www.iinteractive.com>
74
75This library is free software; you can redistribute it and/or modify
76it under the same terms as Perl itself.
77
78=cut