release 0.07006
[dbsrgits/DBIx-Class-Schema-Loader.git] / lib / DBIx / Class / Schema / Loader / RelBuilder / Compat / v0_040.pm
CommitLineData
7824616e 1package DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040;
2
3use strict;
4use warnings;
942bd5e0 5use mro 'c3';
19b7d71c 6use base 'DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_05';
ecf930e6 7use Carp::Clan qw/^DBIx::Class/;
39b22ca9 8use Lingua::EN::Inflect::Number ();
7824616e 9
e94ccbea 10our $VERSION = '0.07006';
7824616e 11
39ef3bfe 12sub _relnames_and_method {
057fbb08 13 my ( $self, $local_moniker, $rel, $cond, $uniqs, $counters ) = @_;
14
15 my $remote_moniker = $rel->{remote_source};
16 my $remote_table = $self->{schema}->source( $remote_moniker )->from;
17
18 my $local_table = $self->{schema}->source($local_moniker)->from;
19 my $local_cols = $rel->{local_columns};
20
21 # for single-column case, set the remote relname to just the column name
22 my $remote_relname =
23 scalar keys %{$cond} == 1
24 ? $self->_inflect_singular( values %$cond )
25 : $self->_inflect_singular( lc $remote_table );
26
27 # If more than one rel between this pair of tables, use the local
28 # col names to distinguish
29 my $local_relname;
30 if ($counters->{$remote_moniker} > 1) {
31 my $colnames = '_' . join( '_', @$local_cols );
32 $remote_relname .= $colnames if keys %$cond > 1;
33 $local_relname = $self->_inflect_plural( lc($local_table) . $colnames );
34 } else {
35 $local_relname = $self->_inflect_plural(lc $local_table);
7824616e 36 }
37
057fbb08 38 return ( $local_relname, $remote_relname, 'has_many' );
7824616e 39}
40
057fbb08 41sub _remote_attrs { }
fa6f8d4e 42
818c6a0c 43=head1 NAME
44
45DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040 - RelBuilder for
46compatibility with DBIx::Class::Schema::Loader version 0.04006
47
48=head1 DESCRIPTION
49
ecf930e6 50See L<DBIx::Class::Schema::Loader::Base/naming> and
51L<DBIx::Class::Schema::Loader::RelBuilder>.
52
53=head1 AUTHOR
54
55See L<DBIx::Class::Schema::Loader/AUTHOR> and L<DBIx::Class::Schema::Loader/CONTRIBUTORS>.
56
57=head1 LICENSE
58
59This library is free software; you can redistribute it and/or modify it under
60the same terms as Perl itself.
818c6a0c 61
62=cut
ecf930e6 63
641;