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