2011-05-12 75 views
3

我正在使用DBIx::Class::Schema::Loader爲我的數據庫創建一個靜態ORM。我用下面的方法來爲ResultSetResult類,我可以插普通的潛艇到創建它並指定基類:DBIx :: Class :: Schema :: Loader ResultSource基類

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' ], 
); 

這個工程就像一個魅力,但我不能找出如何創建一個基類ResultSource。我想插一子成類,這樣我可以這樣做(僞代碼):

$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; 
} 

誰能告訴我如何告訴加載器使用基類ResultSource類,我可以將上面的東西插入到?

謝謝!

回答

相關問題