Add an explicit Sub::Quote dep in ::_Util
[dbsrgits/DBIx-Class-Historic.git] / lib / DBIx / Class / ResultSourceProxy.pm
CommitLineData
75d07914 1package # hide from PAUSE
c0e7b4e5 2 DBIx::Class::ResultSourceProxy;
b98e75f6 3
4use strict;
5use warnings;
6
8d73fcd4 7use base 'DBIx::Class';
d009cb7d 8use mro 'c3';
8d73fcd4 9
10use Scalar::Util 'blessed';
e5053694 11use DBIx::Class::_Util qw( quote_sub fail_on_internal_call );
a93c65f2 12use namespace::clean;
b98e75f6 13
a93c65f2 14__PACKAGE__->mk_group_accessors('inherited_ro_instance' => 'source_name');
15
16sub get_inherited_ro_instance { shift->get_inherited(@_) }
b98e75f6 17
93405cf0 18sub set_inherited_ro_instance {
a93c65f2 19 my $self = shift;
93405cf0 20
a93c65f2 21 $self->throw_exception ("Cannot set @{[shift]} on an instance")
22 if blessed $self;
93405cf0 23
a93c65f2 24 $self->set_inherited(@_);
93405cf0 25}
26
5ac6a044 27
b98e75f6 28sub add_columns {
29 my ($class, @cols) = @_;
1f23a877 30 my $source = $class->result_source_instance;
31 $source->add_columns(@cols);
32 foreach my $c (grep { !ref } @cols) {
157ce0cf 33 # If this is an augment definition get the real colname.
34 $c =~ s/^\+//;
35
1f23a877 36 $class->register_column($c => $source->column_info($c));
37 }
b98e75f6 38}
39
e5053694 40sub add_column {
41 DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
42 shift->add_columns(@_)
43}
002a359a 44
002a359a 45
a93c65f2 46sub add_relationship {
47 my ($class, $rel, @rest) = @_;
48 my $source = $class->result_source_instance;
49 $source->add_relationship($rel => @rest);
50 $class->register_relationship($rel => $source->relationship_info($rel));
bc0c9800 51}
52
b98e75f6 53
a93c65f2 54# legacy resultset_class accessor, seems to be used by cdbi only
e5053694 55sub iterator_class {
56 DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and fail_on_internal_call;
57 shift->result_source_instance->resultset_class(@_)
58}
a83cdbf2 59
a93c65f2 60for my $method_to_proxy (qw/
61 source_info
62 result_class
63 resultset_class
64 resultset_attributes
bc0c9800 65
a93c65f2 66 columns
67 has_column
034d0be4 68
a93c65f2 69 remove_column
70 remove_columns
87f0da6a 71
a93c65f2 72 column_info
52416317 73 columns_info
a93c65f2 74 column_info_from_storage
1bc0b925 75
a93c65f2 76 set_primary_key
77 primary_columns
89170201 78 sequence
1bc0b925 79
a93c65f2 80 add_unique_constraint
81 add_unique_constraints
8c49f629 82
a93c65f2 83 unique_constraints
84 unique_constraint_names
85 unique_constraint_columns
8c49f629 86
a93c65f2 87 relationships
88 relationship_info
89 has_relationship
90/) {
4006691d 91 quote_sub __PACKAGE__."::$method_to_proxy", sprintf( <<'EOC', $method_to_proxy );
92 DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and DBIx::Class::_Util::fail_on_internal_call;
93 shift->result_source_instance->%s (@_);
94EOC
95
8c49f629 96}
97
b98e75f6 981;