If you want to reuse a configuration (for example connect_info) in a number of models, one way is to overload COMPONENT.

-----------------------------------datacentre.yml-
---
name: DataCentre

Model::DataAsset:
    connect_info:
    - 'dbi:Pg:dbname=dbname;host=host.name;'
    - 'user'
    - 'pass'
    - { AutoCommit: 1 }

-----------------------------------./lib/DataCentre/Model/DataAsset.pm-
package DataCentre::Model::DataAsset;

use strict;
use base qw(Catalyst::Model::DBIC::Schema);
__PACKAGE__->config(
    schema_class => 'DataCentre::Schema::DataAsset'
);
__PACKAGE__->config(session => {flash_to_stash => 1});
1;

-----------------------------------./lib/DataCentre/Model/AnotherAsset.pm-
package DataCentre::Model::AnotherAsset;

use strict;
use warnings;
use Scalar::Defer;
use DataCentre::Model::DataAsset;
use base qw(Catalyst::Model::DBIC::Schema);

__PACKAGE__->config(
    schema_class => 'DataCentre::Schema::AnotherAsset'
);

sub COMPONENT { my ($class, $c, $args, @rest) = @_;
    $args = $class->merge_config_hashes($c->config->{'Model::DataAsset'} ||{}, $args ||{});
    $class->next::method($c, $args, @rest);
} 

1;
My tags:
 
Popular tags:
  model configuration connect_info component
Powered by Catalyst
Powered by MojoMojo Hosted by Shadowcat - Managed by Nordaaker