Remove dead code commented out since 2006 ( 953a18ef )
[dbsrgits/DBIx-Class.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 'DBIx::Class';
8
9 use Scalar::Util 'blessed';
10 use DBIx::Class::_Util 'quote_sub';
11 use namespace::clean;
12
13 __PACKAGE__->mk_group_accessors('inherited_ro_instance' => 'source_name');
14
15 sub get_inherited_ro_instance {  shift->get_inherited(@_) }
16
17 sub set_inherited_ro_instance {
18   my $self = shift;
19
20   $self->throw_exception ("Cannot set @{[shift]} on an instance")
21     if blessed $self;
22
23   $self->set_inherited(@_);
24 }
25
26
27 sub add_columns {
28   my ($class, @cols) = @_;
29   my $source = $class->result_source_instance;
30   $source->add_columns(@cols);
31   foreach my $c (grep { !ref } @cols) {
32     # If this is an augment definition get the real colname.
33     $c =~ s/^\+//;
34
35     $class->register_column($c => $source->column_info($c));
36   }
37 }
38
39 sub add_column { shift->add_columns(@_) }
40
41
42 sub add_relationship {
43   my ($class, $rel, @rest) = @_;
44   my $source = $class->result_source_instance;
45   $source->add_relationship($rel => @rest);
46   $class->register_relationship($rel => $source->relationship_info($rel));
47 }
48
49
50 # legacy resultset_class accessor, seems to be used by cdbi only
51 sub iterator_class { shift->result_source_instance->resultset_class(@_) }
52
53 for my $method_to_proxy (qw/
54   source_info
55   result_class
56   resultset_class
57   resultset_attributes
58
59   columns
60   has_column
61
62   remove_column
63   remove_columns
64
65   column_info
66   columns_info
67   column_info_from_storage
68
69   set_primary_key
70   primary_columns
71   sequence
72
73   add_unique_constraint
74   add_unique_constraints
75
76   unique_constraints
77   unique_constraint_names
78   unique_constraint_columns
79
80   relationships
81   relationship_info
82   has_relationship
83 /) {
84   quote_sub __PACKAGE__."::$method_to_proxy", sprintf( <<'EOC', $method_to_proxy );
85     DBIx::Class::_ENV_::ASSERT_NO_INTERNAL_INDIRECT_CALLS and DBIx::Class::_Util::fail_on_internal_call;
86     shift->result_source_instance->%s (@_);
87 EOC
88
89 }
90
91 1;