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