1 package DBIx::Class::ResultSource::MultipleTableInheritance;
5 use parent qw(DBIx::Class::ResultSource::View);
6 use namespace::autoclean;
7 use Method::Signatures::Simple;
8 use Carp::Clan qw/^DBIx::Class/;
12 # On construction, we hook $self->result_class->result_source_instance
13 # if present to get the superclass' source object
15 # When attached to a schema, we need to add sources to that schema with
16 # appropriate relationships for the foreign keys so the concrete tables
19 # We also generate our own view definition using this class' concrete table
20 # and the view for the superclass, and stored procedures for the insert,
21 # update and delete operations on this view.
23 # deploying the postgres rules through SQLT may be a pain though.
25 __PACKAGE__->mk_group_accessors(simple => qw(parent_source));
27 method new ($class: @args) {
28 my $new = $class->next::method(@args);
29 my $rc = $new->result_class;
30 if (my $meth = $rc->can('result_source_instance')) {
31 $new->parent_source($rc->$meth);
34 $new->_attach_additional_sources;
39 method _attach_additional_sources () {
40 my $raw_name = $self->_raw_source_name;
43 method _raw_source_name () {
44 my $base = $self->source_name;
45 confess "Can't generate raw source name when we don't have a source_name"
50 method add_columns (@args) {
51 my $ret = $self->next::method(@args);
52 $_->{originally_defined_in} ||= $self->name for values %{$self->_columns};