Merge 'bulk_create' into 'DBIx-Class-current'
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / ResultSourceProxy.pm
1 package # hide from PAUSE
2     DBIx::Class::ResultSourceProxy;
3
4 use strict;
5 use warnings;
6
7 use base qw/DBIx::Class/;
8 use Scalar::Util qw/blessed/;
9 use Carp::Clan qw/^DBIx::Class/;
10
11 sub iterator_class  { shift->result_source_instance->resultset_class(@_) }
12 sub resultset_class { shift->result_source_instance->resultset_class(@_) }
13 sub result_class { shift->result_source_instance->result_class(@_) }
14 sub source_info { shift->result_source_instance->source_info(@_) }
15
16 sub set_inherited_ro_instance {
17     my $self = shift;
18
19     croak "Cannot set @{[shift]} on an instance" if blessed $self;
20
21     return $self->set_inherited(@_);
22 }
23
24 sub get_inherited_ro_instance {
25     return shift->get_inherited(@_);
26 }
27
28 __PACKAGE__->mk_group_accessors('inherited_ro_instance' => 'source_name');
29
30
31 sub resultset_attributes {
32   shift->result_source_instance->resultset_attributes(@_);
33 }
34
35 sub add_columns {
36   my ($class, @cols) = @_;
37   my $source = $class->result_source_instance;
38   $source->add_columns(@cols);
39   foreach my $c (grep { !ref } @cols) {
40     $class->register_column($c => $source->column_info($c));
41   }
42 }
43
44 *add_column = \&add_columns;
45
46 sub has_column {
47   shift->result_source_instance->has_column(@_);
48 }
49
50 sub column_info {
51   shift->result_source_instance->column_info(@_);
52 }
53
54 sub column_info_from_storage {
55   shift->result_source_instance->column_info_from_storage(@_);
56 }
57
58 sub columns {
59   shift->result_source_instance->columns(@_);
60 }
61
62 sub remove_columns {
63   shift->result_source_instance->remove_columns(@_);
64 }
65
66 *remove_column = \&remove_columns;
67
68 sub set_primary_key {
69   shift->result_source_instance->set_primary_key(@_);
70 }
71
72 sub primary_columns {
73   shift->result_source_instance->primary_columns(@_);
74 }
75
76 sub add_unique_constraint {
77   shift->result_source_instance->add_unique_constraint(@_);
78 }
79
80 sub unique_constraints {
81   shift->result_source_instance->unique_constraints(@_);
82 }
83
84 sub unique_constraint_names {
85   shift->result_source_instance->unique_constraint_names(@_);
86 }
87
88 sub unique_constraint_columns {
89   shift->result_source_instance->unique_constraint_columns(@_);
90 }
91
92 sub add_relationship {
93   my ($class, $rel, @rest) = @_;
94   my $source = $class->result_source_instance;
95   $source->add_relationship($rel => @rest);
96   $class->register_relationship($rel => $source->relationship_info($rel));
97 }
98
99 sub relationships {
100   shift->result_source_instance->relationships(@_);
101 }
102
103 sub relationship_info {
104   shift->result_source_instance->relationship_info(@_);
105 }
106
107 1;