You can add stuff to __PACKAGE__->config in and use that info in your Schema then by making use of Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy.

in you add something (e.g.: a path) to the config of your Model.

    'Model::DB' => {
        my_path      => __PACKAGE__->path_to(qw/ root static/ ),

Add the trait to your Model so the config option is passed on to your Schema. (lib/MyApp/Model/

package MyApp::Model::DB;
    traits       => 'SchemaProxy',

then you need to create an accessor in You can use Moose or Class::Accessor::Grouped to make that accessor (see the documentation of Catalyst::TraitFor::Model::DBIC::Schema::SchemaProxy for details)

use Moose;
has 'my_path' => (
    is => 'rw',

now you can access the path on your schema like so


sub path {
    my $self = shift;
    return $self->result_source->schema->my_path;

But what if you need the config option at creation time when you can't yet call $self on the schema. (I needed this to avoid hardcoding DBIx::Class::InflateColumn::FS fs_column_path in my ResultSource)

package MyApp::Model::DB;

the Schema fs_path work
    traits       => 'SchemaProxy',

use Moose;
# set fs_column_path as specified in MyApp->config
around 'COMPONENT' => sub {
    my ($orig, $class, $app, $args) = @_;
    my $self = $class->$orig($app, $args);
    $self->schema->source('Tracks')->column_info('file')->{fs_column_path} = $self->schema->my_path();
    return $self;

This sets the fs_column_path value of the file column in your ResultSource to the option you provide in your application config.

My tags:
Popular tags:
Powered by Catalyst
Powered by MojoMojo Hosted by Shadowcat - Managed by Nordaaker