2 package Class::MOP::Method::Generated;
9 our $VERSION = '0.82_01';
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];
37 or die "capture key should start with \@, \% or \$: $_";
50 sub _add_line_directive {
51 my ( $self, %args ) = @_;
55 if ( my $ctx = ( $args{context} || $self->definition_context ) ) {
57 if ( my $desc = $ctx->{description} ) {
58 $file = "$desc defined at $ctx->{file}";
63 ( $line, $file ) = ( 0, "generated method (unknown origin)" );
66 my $code = $args{code};
68 # if it's an array of lines, join it up
69 # don't use newlines so that the definition context is more meaningful
70 $code = join(@$code, ' ') if ref $code;
72 return qq{#line $line "$file"\n} . $code;
76 my ( $self, %args ) = @_;
78 my $code = $self->_add_line_directive(%args);
80 $self->_eval_closure($args{environment}, $code);
91 Class::MOP::Method::Generated - Abstract base class for generated methods
95 This is a C<Class::MOP::Method> subclass which is subclassed by
96 C<Class::MOP::Method::Accessor> and
97 C<Class::MOP::Method::Constructor>.
99 It is not intended to be used directly.
103 Stevan Little E<lt>stevan@iinteractive.comE<gt>
105 =head1 COPYRIGHT AND LICENSE
107 Copyright 2006-2009 by Infinity Interactive, Inc.
109 L<http://www.iinteractive.com>
111 This library is free software; you can redistribute it and/or modify
112 it under the same terms as Perl itself.