X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=lib%2FDBIx%2FClass%2FSchema%2FLoader%2FBase.pm;h=2a676843f0a418d90947fd619f4aab2078b0eeb0;hb=dde95f2c6188ae6182da0f32320e7f1c9da0a90a;hp=49c035928a33bc927e1f9e9d3d80634b89680dbc;hpb=f1740f1b11e070f4e794fa43c606323d3ef528ab;p=dbsrgits%2FDBIx-Class-Schema-Loader.git diff --git a/lib/DBIx/Class/Schema/Loader/Base.pm b/lib/DBIx/Class/Schema/Loader/Base.pm index 49c0359..2a67684 100644 --- a/lib/DBIx/Class/Schema/Loader/Base.pm +++ b/lib/DBIx/Class/Schema/Loader/Base.pm @@ -77,6 +77,8 @@ __PACKAGE__->mk_group_ro_accessors('simple', qw/ class_to_table uniq_to_primary quiet + + filter_generated_text /); @@ -682,6 +684,21 @@ Automatically promotes the largest unique constraints with non-nullable columns 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, or do anything else that you want. + +If this exists but fails to return text matching C, 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 @@ -1655,7 +1672,15 @@ sub _write_classfile { $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) {