use File::Temp 'tempfile';
use namespace::clean;
-our $VERSION = '0.07036_04';
+our $VERSION = '0.07038';
__PACKAGE__->mk_group_ro_accessors('simple', qw/
schema
use_moose
only_autoclean
overwrite_modifications
+ generated_classes
relationship_attrs
object|DBIx::Class::Schema::Loader::Table> argument (which stringifies to the
unqualified table name) and returning a scalar moniker
+The function is also passed a coderef that can be called with either
+of the hashref forms to get the moniker mapped accordingly. This is
+useful if you need to handle some monikers specially, but want to use
+the hashref form for the rest.
+
=back
If the hash entry does not exist, or the function returns a false
},
Given the table C<foo.bar>, the code ref would be called with the
-arguments C<foo> and C<schema>.
+arguments C<foo> and C<schema>, plus a coderef similar to the one
+described in L</moniker_map>.
L</moniker_map> takes precedence over this.
schema_class => name of the schema class we are building,
column_info => hashref of column info (data_type, is_nullable, etc),
}
+ coderef ref that can be called with a hashref map
the L<table object|DBIx::Class::Schema::Loader::Table> stringifies to the
unqualified table name.
and relationships that would have been named C<bar> will now be named C<baz>
except that in the table whose moniker is C<Foo> it will be named C<blat>.
-If it is a coderef, the argument passed will be a hashref of this form:
+If it is a coderef, it will be passed a hashref of this form:
{
name => default relationship name,
link_rel_name => name of the relationship to the link table
}
+In addition it is passed a coderef that can be called with a hashref map.
+
DBICSL will try to use the value returned as the relationship name.
=head2 inflect_plural
$self->{class_to_table} = {};
$self->{classes} = {};
$self->{_upgrading_classes} = {};
+ $self->{generated_classes} = [];
$self->{schema_class} ||= ( ref $self->{schema} || $self->{schema} );
$self->{schema} ||= $self->{schema_class};
# The relationship loader needs a working schema
local $self->{quiet} = 1;
local $self->{dump_directory} = $self->{temp_directory};
+ local $self->{generated_classes} = [];
$self->_reload_classes(\@tables);
$self->_load_relationships(\@tables);
}
}
+ push @{$self->generated_classes}, $class;
+
$text .= $self->_sig_comment(
$self->version_to_dump,
POSIX::strftime('%Y-%m-%d %H:%M:%S', localtime)
}
}
elsif( $map && ref $map eq 'CODE' ) {
- $new_ident = $map->( $ident, $default_ident, @extra );
+ my $cb = sub {
+ my ($cb_map) = @_;
+ croak "reentered map must be a hashref"
+ unless 'HASH' eq ref($cb_map);
+ return $self->_run_user_map($cb_map, $default_code, $ident, @extra);
+ };
+ $new_ident = $map->( $ident, $default_ident, @extra, $cb );
}
$new_ident ||= $default_ident;
contain multiple entries per table for the original and normalized table
names, as above in L</monikers>.
+=head2 generated_classes
+
+Returns an arrayref of classes that were actually generated (i.e. not
+skipped because there were no changes).
+
=head1 NON-ENGLISH DATABASES
If you use the loader on a database with table and column names in a language