Unqualify imported functions
[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 Sub::Name qw/subname/;
10 use namespace::clean;
11
12 __PACKAGE__->mk_group_accessors('inherited_ro_instance' => 'source_name');
13
14 sub get_inherited_ro_instance {  shift->get_inherited(@_) }
15
16 sub set_inherited_ro_instance {
17   my $self = shift;
18
19   $self->throw_exception ("Cannot set @{[shift]} on an instance")
20     if blessed $self;
21
22   $self->set_inherited(@_);
23 }
24
25
26 sub add_columns {
27   my ($class, @cols) = @_;
28   my $source = $class->result_source_instance;
29   $source->add_columns(@cols);
30   foreach my $c (grep { !ref } @cols) {
31     # If this is an augment definition get the real colname.
32     $c =~ s/^\+//;
33
34     $class->register_column($c => $source->column_info($c));
35   }
36 }
37
38 sub add_column { shift->add_columns(@_) }
39
40
41 sub add_relationship {
42   my ($class, $rel, @rest) = @_;
43   my $source = $class->result_source_instance;
44   $source->add_relationship($rel => @rest);
45   $class->register_relationship($rel => $source->relationship_info($rel));
46 }
47
48
49 # legacy resultset_class accessor, seems to be used by cdbi only
50 sub iterator_class { shift->result_source_instance->resultset_class(@_) }
51
52 for my $method_to_proxy (qw/
53   source_info
54   result_class
55   resultset_class
56   resultset_attributes
57
58   columns
59   has_column
60
61   remove_column
62   remove_columns
63
64   column_info
65   columns_info
66   column_info_from_storage
67
68   set_primary_key
69   primary_columns
70   _pri_cols
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   no strict qw/refs/;
85   *{__PACKAGE__."::$method_to_proxy"} = subname $method_to_proxy => sub {
86     shift->result_source_instance->$method_to_proxy (@_);
87   };
88 }
89
90 1;