2 package Class::MOP::Method::Generated;
10 $VERSION = eval $VERSION;
11 our $AUTHORITY = 'cpan:STEVAN';
13 use base 'Class::MOP::Method';
18 confess __PACKAGE__ . " is an abstract base class, you must provide a constructor.";
21 sub is_inline { $_[0]{is_inline} }
23 sub definition_context { $_[0]{definition_context} }
25 sub _initialize_body {
26 confess "No body to initialize, " . __PACKAGE__ . " is an abstract base class";
30 # my ($self, $captures, $sub_body) = @_;
31 my $__captures = $_[1];
42 or die "capture key should start with \@, \% or \$: $_";
57 sub _add_line_directive {
58 my ( $self, %args ) = @_;
62 if ( my $ctx = ( $args{context} || $self->definition_context ) ) {
64 if ( my $desc = $ctx->{description} ) {
65 $file = "$desc defined at $ctx->{file}";
70 ( $line, $file ) = ( 0, "generated method (unknown origin)" );
73 my $code = $args{code};
75 # if it's an array of lines, join it up
76 # don't use newlines so that the definition context is more meaningful
77 $code = join(@$code, ' ') if ref $code;
79 return qq{#line $line "$file"\n} . $code;
83 my ( $self, %args ) = @_;
85 my $code = $self->_add_line_directive(%args);
87 return $self->_eval_closure($args{environment}, $code);
98 Class::MOP::Method::Generated - Abstract base class for generated methods
102 This is a C<Class::MOP::Method> subclass which is subclassed by
103 C<Class::MOP::Method::Accessor> and
104 C<Class::MOP::Method::Constructor>.
106 It is not intended to be used directly.
110 Stevan Little E<lt>stevan@iinteractive.comE<gt>
112 =head1 COPYRIGHT AND LICENSE
114 Copyright 2006-2009 by Infinity Interactive, Inc.
116 L<http://www.iinteractive.com>
118 This library is free software; you can redistribute it and/or modify
119 it under the same terms as Perl itself.