I use DBIx::Class::Schema::Loaderto create a static ORM in my database. I use the following method to create it and set the base classes for the classes ResultSetand Result, which I can connect to common subsets:
make_schema_at(
'MyApp::Schema',
{
debug => 1,
dump_directory => '/home/rob/projects/myapp/MyApp/lib',
overwrite_modifications => 1,
components=> ['EncodedColumn'],
use_namespaces => 1,
result_base_class => 'MyApp::Schema::ResultBase',
default_resultset_class => 'ResultSetBase'
},
[ 'DBI:mysql:database=mydb;host=localhost;port=3306','user', 'pass' ],
);
It works like a charm, but I can’t find out how to create a base class for ResultSource. I would like to connect sub to this class so that I can do something like (pseudocode):
$c->model('DB')->source->('Account')->getParentSource('Project');
ResultSourceBase.pm:
sub getParentSource {
my ($self,$parent) = @_;
foreach $relation in $self->relations
if ($relation->identifier eq $parent)
return $relation->source;
return $self;
}
Can someone tell me how to tell the loader to use a base class ResultSourcein which I can connect things like above?
Thank!
source
share