use base 'Class::MOP::Method';
-use constant _PRINT_SOURCE => $ENV{MOP_PRINT_SOURCE} ? 1 : 0;
-
## accessors
sub new {
}
sub _eval_closure {
- # my ($self, $captures, $sub_body) = @_;
- my $__captures = $_[1];
+ my ($self, $__captures, $sub_body) = @_;
my $code;
. $_ . q['}};];
} keys %$__captures
),
- $_[2];
- print STDERR "\n", $_[0]->name, ":\n", $source, "\n" if _PRINT_SOURCE;
+ $sub_body;
+
+ $self->_dump_source($source) if $ENV{MOP_PRINT_SOURCE};
+
$code = eval $source;
$@;
};
return ( $code, $e );
}
+sub _dump_source {
+ my ( $self, $source ) = @_;
+
+ my $output;
+ if ( eval { require Perl::Tidy } ) {
+ require File::Spec;
+
+ my $rc_file = File::Spec->catfile(
+ $INC{'Class/MOP/Method/Generated.pm'},
+ ('..') x 5,
+ 'perltidyrc'
+ );
+ warn $rc_file;
+
+ my %p = (
+ source => \$source,
+ destination => \$output,
+ );
+ $p{perltidyrc} = $rc_file
+ if -f $rc_file;
+
+ Perl::Tidy::perltidy(%p);
+ }
+ else {
+ $output = $source;
+ }
+
+ print STDERR "\n", $self->name, ":\n", $output, "\n";
+}
+
sub _add_line_directive {
my ( $self, %args ) = @_;
--- /dev/null
+-l=78
+-i=4
+-ci=4
+-se
+-b
+-bar
+-boc
+-vt=0
+-vtc=0
+-cti=0
+-pt=1
+-bt=1
+-sbt=1
+-bbt=1
+-nolq
+-npro
+-nsfs
+--opening-hash-brace-right
+--no-outdent-long-comments
+-wbb="% + - * / x != == >= <= =~ !~ < > | & >= < = **= += *= &= <<= &&= -= /= |= >>= ||= .= %= ^= x="