DBIx::Class::Schema::Loader
データベースに静的ORMを作成するために使用しています。次のメソッドを使用して作成し、ジェネリックサブをプラグインできるクラスの基本クラスResultSet
を指定します。Result
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
上記のようなものをプラグインできる基本クラスを使用するようにローダーに指示する方法を誰かに教えてもらえますか?
ありがとう!