2cc28c4b14e40a1e1bc07799e43b98cad02c90c0
[gitmo/Moose.git] / lib / Moose / Compiler / Moose.pm
1
2 package Moose::Compiler::Moose;
3 use Moose;
4
5 our $VERSION = '0.01';
6
7 with 'Moose::Compiler::Engine';
8
9 sub 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
35 1;
36
37 __END__
38
39 =pod
40
41 =head1 NAME
42
43 Moose::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
53 This will return the metaclass associated with the given role.
54
55 =item B<compile_class>
56
57 =back
58
59 =head1 BUGS
60
61 All complex software has bugs lurking in it, and this module is no 
62 exception. If you find a bug please either email me, or add the bug
63 to cpan-RT.
64
65 =head1 AUTHOR
66
67 Stevan Little E<lt>stevan@iinteractive.comE<gt>
68
69 =head1 COPYRIGHT AND LICENSE
70
71 Copyright 2006 by Infinity Interactive, Inc.
72
73 L<http://www.iinteractive.com>
74
75 This library is free software; you can redistribute it and/or modify
76 it under the same terms as Perl itself. 
77
78 =cut