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