Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add DBIx::Connector attribute.

  • Loading branch information...
commit d5d04511943fb99e339f1bcfcea15087110ca998 1 parent 2cd8297
@theory authored
Showing with 14 additions and 0 deletions.
  1. +2 −0  Makefile.PL
  2. +12 −0 lib/MyApp.pm
View
2  Makefile.PL
@@ -10,6 +10,8 @@ requires 'Catalyst::Runtime' => '5.80013';
requires 'Catalyst::Plugin::ConfigLoader';
requires 'Catalyst::Plugin::Static::Simple';
requires 'Catalyst::Action::RenderView';
+requires 'DBIx::Connector' => '0.30';
+requires 'Exception::Class::DBI' => '1.00';
requires 'parent';
requires 'Config::General'; # This should reflect the config file format you've chosen
# See Catalyst::Plugin::ConfigLoader for supported formats
View
12 lib/MyApp.pm
@@ -4,6 +4,9 @@ use strict;
use warnings;
use Catalyst::Runtime 5.80;
+use Moose;
+use DBIx::Connector;
+use Exception::Class::DBI;
# Set flags and add plugins for the application
#
@@ -36,6 +39,15 @@ __PACKAGE__->config( name => 'MyApp' );
# Start the application
__PACKAGE__->setup();
+has conn => (is => 'ro', lazy => 1, default => sub {
+ DBIx::Connector->new( 'dbi:Pg:dbname=myapp', 'postgres', '', {
+ PrintError => 0,
+ RaiseError => 0,
+ HandleError => Exception::Class::DBI->handler,
+ AutoCommit => 1,
+ pg_enable_utf8 => 1,
+ });
+});
=head1 NAME
Please sign in to comment.
Something went wrong with that request. Please try again.