7b4451ee489a26abff97de97e2fe803a7e419294
[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 Class::C3;
6
7 use base 'DBIx::Class::Schema::Loader::RelBuilder';
8
9 sub _uniq_fk_rel {
10     my ($self, $local_moniker, $local_relname, $local_cols, $uniqs) = @_;
11
12     return ('has_many', $local_relname);
13 }
14
15 sub _remote_attrs { }
16
17 sub _remote_relname {
18     my ($self, $remote_table, $cond) = @_;
19
20     my $remote_relname;
21     # for single-column case, set the remote relname to the column
22     # name, to make filter accessors work
23     if(scalar keys %{$cond} == 1) {
24         $remote_relname = $self->_inflect_singular(values %{$cond});
25     }
26     else {
27         $remote_relname = $self->_inflect_singular(lc $remote_table);
28     }
29
30     return $remote_relname;
31 }
32
33 sub _multi_rel_local_relname {
34     my ($self, $local_table, $local_cols) = @_;
35
36     my $colnames = q{_} . join(q{_}, @$local_cols);
37     my $local_relname = $self->_inflect_plural( lc($local_table) . $colnames );
38
39     return $local_relname;
40 }
41
42 1;
43
44 =head1 NAME
45
46 DBIx::Class::Schema::Loader::RelBuilder::Compat::v0_040 - RelBuilder for
47 compatibility with DBIx::Class::Schema::Loader version 0.04006
48
49 =head1 DESCRIPTION
50
51 See L<DBIx::Class::Schema::Loader::Base/naming>.
52
53 =cut