=head2 new
-Arguments: $base object
+Arguments: $loader object
=head2 generate_code
=cut
__PACKAGE__->mk_group_accessors('simple', qw/
- base
+ loader
schema
inflect_plural
inflect_singular
/);
sub new {
- my ( $class, $base ) = @_;
+ my ($class, $loader) = @_;
# from old POD about this constructor:
# C<$schema_class> should be a schema class name, where the source
# are better documented in L<DBIx::Class::Schema::Loader::Base>.
my $self = {
- base => $base,
- schema => $base->schema,
- inflect_plural => $base->inflect_plural,
- inflect_singular => $base->inflect_singular,
- relationship_attrs => $base->relationship_attrs,
- rel_collision_map => $base->rel_collision_map,
- rel_name_map => $base->rel_name_map,
+ loader => $loader,
+ schema => $loader->schema,
+ inflect_plural => $loader->inflect_plural,
+ inflect_singular => $loader->inflect_singular,
+ relationship_attrs => $loader->relationship_attrs,
+ rel_collision_map => $loader->rel_collision_map,
+ rel_name_map => $loader->rel_name_map,
_temp_classes => [],
};
- weaken $self->{base}; #< don't leak
+ weaken $self->{loader}; #< don't leak
bless $self => $class;
return $relname if $relname eq 'id'; # this shouldn't happen, but just in case
- my $table = $self->base->tables->{$moniker};
+ my $table = $self->loader->tables->{$moniker};
- if ($self->base->_is_result_class_method($relname, $table)) {
+ if ($self->loader->_is_result_class_method($relname, $table)) {
if (my $map = $self->rel_collision_map) {
for my $re (keys %$map) {
if (my @matches = $relname =~ /$re/) {
}
my $new_relname = $relname;
- while ($self->base->_is_result_class_method($new_relname, $table)) {
+ while ($self->loader->_is_result_class_method($new_relname, $table)) {
$new_relname .= '_rel'
}
if ($counters->{$remote_moniker} > 1) {
my $relationship_exists = 0;
- if (-f (my $existing_remote_file = $self->base->get_dump_filename($remote_class))) {
+ if (-f (my $existing_remote_file = $self->loader->get_dump_filename($remote_class))) {
my $class = "${remote_class}Temporary";
if (not Class::Inspector->loaded($class)) {
my $local_cols = $rel->{local_columns};
# for single-column case, set the remote relname to just the column name
- my $remote_relname =
+ my ($remote_relname) =
scalar keys %{$cond} == 1
? $self->_inflect_singular( values %$cond )
: $self->_inflect_singular( lc $remote_table );
if ($counters->{$remote_moniker} > 1) {
my $colnames = '_' . join( '_', @$local_cols );
$remote_relname .= $colnames if keys %$cond > 1;
- $local_relname = $self->_inflect_plural( lc($local_table) . $colnames );
+ ($local_relname) = $self->_inflect_plural( lc($local_table) . $colnames );
} else {
- $local_relname = $self->_inflect_plural(lc $local_table);
+ ($local_relname) = $self->_inflect_plural(lc $local_table);
}
return ( $local_relname, $remote_relname, 'has_many' );
$local_relname = lc($local_table) . $colnames;
$local_relname_uninflected = $local_relname;
- $local_relname = $self->_inflect_plural( $local_relname );
+ ($local_relname) = $self->_inflect_plural( $local_relname );
} else {
$local_relname_uninflected = lc $local_table;
- $local_relname = $self->_inflect_plural(lc $local_table);
+ ($local_relname) = $self->_inflect_plural(lc $local_table);
}
my $remote_method = 'has_many';
if ($self->_array_eq([ $local_source->primary_columns ], $local_cols) ||
grep { $self->_array_eq($_->[1], $local_cols) } @$uniqs) {
$remote_method = 'might_have';
- $local_relname = $self->_inflect_singular($local_relname_uninflected);
+ ($local_relname) = $self->_inflect_singular($local_relname_uninflected);
}
return ( $local_relname, $remote_relname, $remote_method );