Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package NADS::Schema;
- use utf8;
- use Moose;
- use MooseX::Types::Moose qw/Str/;
- use Data::Dumper;
- extends 'DBIx::Class::Schema';
- our $VERSION = 1;
- __PACKAGE__->load_namespaces;
- __PACKAGE__->load_components('DeploymentHandler::VersionStorage::Standard::Component');
- has 'fs_datadir' => (
- is => 'rw',
- isa => Str,
- );
- around connection => sub {
- my $orig = shift;
- my ($self, $connect_info) = @_;
- return $self if !defined($connect_info->{attributes});
- my $attributes = delete $connect_info->{attributes};
- $self = $self->$orig($connect_info);
- foreach my $key ( keys %$attributes )
- {
- if($self->can($key))
- {
- $self->$key($attributes->{$key});
- }
- }
- $self
- };
- sub connect_config {
- my ($self, $config) = @_;
- return $self->connect({
- dsn => $config->database->dsn,
- username => $config->database->username,
- password => $config->database->password,
- %{ $config->database->args },
- %{ $config->database->attributes },
- });
- }
- 1;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement