bump version # and update changes
[gitmo/Class-MOP.git] / lib / Class / MOP / Method / Generated.pm
CommitLineData
565f0cbb 1
2package Class::MOP::Method::Generated;
3
4use strict;
5use warnings;
6
7use Carp 'confess';
8
7329b9e2 9our $VERSION = '0.70';
d519662a 10$VERSION = eval $VERSION;
565f0cbb 11our $AUTHORITY = 'cpan:STEVAN';
12
13use base 'Class::MOP::Method';
14
15sub new {
16 my $class = shift;
17 my %options = @_;
18
b38f3848 19 ($options{package_name} && $options{name})
32202ce2 20 || confess "You must supply the package_name and name parameters $Class::MOP::Method::UPGRADE_ERROR_TEXT";
b38f3848 21
0bfc85b8 22 my $self = $class->_new(\%options);
565f0cbb 23
24 $self->initialize_body;
25
26 return $self;
27}
28
e3a72dbc 29sub _new {
0bfc85b8 30 my $class = shift;
31 my $options = @_ == 1 ? $_[0] : {@_};
e3a72dbc 32
0bfc85b8 33 $options->{is_inline} ||= 0;
34 $options->{body} ||= undef;
e3a72dbc 35
0bfc85b8 36 bless $options, $class;
e3a72dbc 37}
38
565f0cbb 39## accessors
40
8683db0e 41sub is_inline { (shift)->{'is_inline'} }
565f0cbb 42
43sub initialize_body {
44 confess "No body to initialize, " . __PACKAGE__ . " is an abstract base class";
45}
46
47
48
491;
50
51__END__
52
53=pod
54
55=head1 NAME
56
57Class::MOP::Method::Generated - Abstract base class for generated methods
58
59=head1 DESCRIPTION
60
61This is a C<Class::MOP::Method> subclass which is used interally
62by C<Class::MOP::Method::Accessor> and C<Class::MOP::Method::Constructor>.
63
64=head1 METHODS
65
66=over 4
67
68=item B<new (%options)>
69
70This creates the method based on the criteria in C<%options>,
71these options are:
72
73=over 4
74
75=item I<is_inline>
76
77This is a boolean to indicate if the method should be generated
78as a closure, or as a more optimized inline version.
79
80=back
81
82=item B<is_inline>
83
84This returns the boolean which was passed into C<new>.
85
86=item B<initialize_body>
87
88This is an abstract method and will throw an exception if called.
89
90=back
91
92=head1 AUTHORS
93
94Stevan Little E<lt>stevan@iinteractive.comE<gt>
95
96=head1 COPYRIGHT AND LICENSE
97
69e3ab0a 98Copyright 2006-2008 by Infinity Interactive, Inc.
565f0cbb 99
100L<http://www.iinteractive.com>
101
102This library is free software; you can redistribute it and/or modify
103it under the same terms as Perl itself.
104
105=cut
106