1 package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040;
6 use Lingua::EN::Inflect::Number ();
8 use base 'DBIx::Class::Schema::Loader::RelBuilder';
10 sub _default_relationship_attrs { +{} }
13 my ($self, $name) = @_;
15 return Lingua::EN::Inflect::Number::to_PL($name);
19 my ($self, $name) = @_;
21 return Lingua::EN::Inflect::Number::to_S($name);
24 sub _relnames_and_method {
25 my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_;
27 my $remote_moniker = $rel->{remote_source};
28 my $remote_table = $self->{schema}->source( $remote_moniker )->from;
30 my $local_table = $self->{schema}->source($local_moniker)->from;
31 my $local_cols = $rel->{local_columns};
33 # for single-column case, set the remote relname to just the column name
35 scalar keys %{$cond} == 1
36 ? $self->_inflect_singular( values %$cond )
37 : $self->_inflect_singular( lc $remote_table );
39 # If more than one rel between this pair of tables, use the local
40 # col names to distinguish
42 if ($counters->{$remote_moniker} > 1) {
43 my $colnames = '_' . join( '_', @$local_cols );
44 $remote_relname .= $colnames if keys %$cond > 1;
45 $local_relname = $self->_inflect_plural( lc($local_table) . $colnames );
47 $local_relname = $self->_inflect_plural(lc $local_table);
50 return ( $local_relname, $remote_relname, 'has_many' );
59 DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040 - RelBuilder for
60 compatibility with DBIx::Class::Schema::Loader version 0.04006
64 See L<DBIx::Class::Schema::Loader::Base/naming>.