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