2 package Moose::Compiler::Perl5;
7 with 'Moose::Compiler::Engine';
10 my ($self, $meta) = @_;
12 $o .= ('package ' . $meta->name . ";\n");
14 $o .= ("use strict;\n");
15 $o .= ("use warnings;\n");
17 $o .= ("our \$VERSION = '" . $meta->version . "';\n");
19 $o .= ("sub new {\n");
20 $o .= (" my (\$class, \%params) = \@_;\n");
21 $o .= (" my \%proto = (\n");
22 foreach my $attr_name ($meta->get_attribute_list) {
23 $o .= (" '" . $attr_name . "' => undef,\n");
26 $o .= (" return bless { \%proto, \%params } => \$class;\n");
30 foreach my $attr_name ($meta->get_attribute_list) {
31 my $attr = $meta->get_attribute($attr_name);
32 $o .= ("sub " . $attr->reader . " {" . ('') . "}\n\n") if $attr->has_reader;
33 $o .= ("sub " . $attr->writer . " {" . ('') . "}\n\n") if $attr->has_writer;
34 $o .= ("sub " . $attr->accessor . " {" . ('') . "}\n\n") if $attr->has_accessor;
35 $o .= ("sub " . $attr->predicate . " {" . ('') . "}\n\n") if $attr->has_predicate;
52 Moose::Compiler::Perl5 - A Moose compiler engine for compiling to Perl 5
62 This will return the metaclass associated with the given role.
64 =item B<compile_class>
70 All complex software has bugs lurking in it, and this module is no
71 exception. If you find a bug please either email me, or add the bug
76 Stevan Little E<lt>stevan@iinteractive.comE<gt>
78 =head1 COPYRIGHT AND LICENSE
80 Copyright 2006 by Infinity Interactive, Inc.
82 L<http://www.iinteractive.com>
84 This library is free software; you can redistribute it and/or modify
85 it under the same terms as Perl itself.