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