From: Matt S Trout Date: Wed, 3 Jun 2009 15:34:42 +0000 (+0100) Subject: start to sketch out code X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=876f65254c0a9ba7d23d434db880ce7cc5a7874b;p=dbsrgits%2FDBIx-Class-ResultSource-MultipleTableInheritance.git start to sketch out code --- diff --git a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm index a25090e..af0f4a4 100644 --- a/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm +++ b/lib/DBIx/Class/ResultSource/MultipleTableInheritance.pm @@ -1,4 +1,11 @@ -use MooseX::Declare; +package DBIx::Class::ResultSource::MultipleTableInheritance; + +use strict; +use warnings; +use parent qw(DBIx::Class::ResultSource::View); +use namespace::autoclean; +use Method::Signatures::Simple; +use Carp::Clan qw/^DBIx::Class/; # how this works: # @@ -15,11 +22,35 @@ use MooseX::Declare; # # deploying the postgres rules through SQLT may be a pain though. -class DBIx::Class::ResultSource::MultipleTableInheritance - extends DBIx::Class::ResultSource::View { +__PACKAGE__->mk_group_accessors(simple => qw(parent_source)); + +method new ($class: @args) { + my $new = $class->next::method(@args); + my $rc = $new->result_class; + if (my $meth = $rc->can('result_source_instance')) { + $new->parent_source($rc->$meth); + } + if ($new->schema) { + $new->_attach_additional_sources; + } + return $new; +} + +method _attach_additional_sources () { + my $raw_name = $self->_raw_source_name; +} + +method _raw_source_name () { + my $base = $self->source_name; + confess "Can't generate raw source name when we don't have a source_name" + unless $base; + return 'Raw::'.$base; +} - - +method add_columns (@args) { + my $ret = $self->next::method(@args); + $_->{originally_defined_in} ||= $self->name for values %{$self->_columns}; + return $ret; } 1;