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