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