package NGCP::Panel::Model::DB;

use strict;
use File::ShareDir 'dist_file';
use Moose;
use MooseX::Types::Moose;
extends 'Catalyst::Model::DBIC::Schema';

use Module::Runtime qw(use_module);

has 'testing' => (is => 'rw', isa => 'Bool', default => 0);

sub setup {
    my ($self) = @_;
    if ($self->testing) {
        my $config_location = dist_file('NGCP-Schema', 'test.conf');
        use_module('NGCP::Schema::Config')->instance
            ->config_file($config_location);
    }
    if($ENV{NGCP_PANEL_CUSTOM_DSN}) {
        use_module('NGCP::Schema::Config')->instance->as_hash;
        use_module('NGCP::Schema::Config')->instance->as_hash
            ->{ngcp_connect_info}{dsn} = $ENV{NGCP_PANEL_CUSTOM_DSN};
    }
}

__PACKAGE__->config(
    connect_info => [],
);

=head1 NAME

NGCP::Panel::Model::DB - Catalyst DBIC Schema Model

=head1 SYNOPSIS

See L<NGCP::Panel>

=head1 DESCRIPTION

L<Catalyst::Model::DBIC::Schema> Model using schema L<NGCP::Schema>

=head1 GENERATED BY

Catalyst::Helper::Model::DBIC::Schema - 0.6

=head1 AUTHOR

Gerhard

=head1 LICENSE

This library is free software, you can redistribute it and/or modify
it under the same terms as Perl itself.

=cut

1;
