class_to_table
uniq_to_primary
quiet
+
+ filter_generated_text
/);
on tables to primary keys, assuming there is only one largest unique
constraint.
+=head2 filter_generated_text
+
+An optional hook that lets you filter the generated text for various classes through
+a function that change it in any way that you want. The function will receive the class
+and text, and returns the new text to use instead. For instance you could add
+custom comment, run C<perltidy>, or do anything else that you want.
+
+If this exists but fails to return text matching C</package/>, no file will be generated.
+
+ filter_generated_base => sub {
+ my ($class, $text) = @_;
+ ...
+ return $new_text;
+ }
+
=head1 METHODS
None of these methods are intended for direct invocation by regular
$text .= qq|$_\n|
for @{$self->{_dump_storage}->{$class} || []};
- # Check and see if the dump is infact differnt
+ if ($self->{filter_generated_text}) {
+ $text = $self->{filter_generated_text}->($class, $text);
+ if (not $text or not $text =~ /package/) {
+ warn("$class skipped due to filter") if $self->debug;
+ return;
+ }
+ }
+
+ # Check and see if the dump is in fact different
my $compare_to;
if ($old_md5) {
--- /dev/null
+use strict;
+use File::Slurp qw(slurp);
+use File::Path;
+use Test::More tests => 4;
+use Test::Exception;
+use lib qw(t/lib);
+use make_dbictest_db;
+use dbixcsl_test_dir qw/$tdir/;
+
+use DBIx::Class::Schema::Loader;
+
+my $dump_path = "$tdir/dump";
+
+my %original_class_data;
+
+{
+ package DBICTest::Schema::1;
+ use base qw/ DBIx::Class::Schema::Loader /;
+ __PACKAGE__->loader_options(
+ dump_directory => $dump_path,
+ filter_generated_text => sub {
+ my ($class, $text) = @_;
+ $original_class_data{$class} = $text;
+ if ($class =~ /::1$/) {
+ $text = "No Gotcha!";
+ }
+ else {
+ $text .= q{"Kilroy was here";};
+ }
+ return $text;
+ },
+ );
+}
+
+DBICTest::Schema::1->connect($make_dbictest_db::dsn);
+
+my $foo = slurp("$dump_path/DBICTest/Schema/1/Result/Foo.pm");
+ok(! -e "$dump_path/DBICTest/Schema/1.pm",
+ "No package means no file written");
+ok($original_class_data{"DBICTest::Schema::1"},
+ "Even though we processed the missing class");
+like($foo, qr/# Created by .* THE FIRST PART/s,
+ "We get the whole autogenerated text");
+like($foo, qr/Kilroy was here/, "Can insert text");
+
+END { rmtree($dump_path, 1, 1); }