File: Base.pm

package info (click to toggle)
librose-db-object-perl 1%3A0.815-1%2Bdeb10u1
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 5,048 kB
  • sloc: perl: 79,670; sql: 28; makefile: 7
file content (36 lines) | stat: -rwxr-xr-x 623 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package MyTest::CDBI::Base;

use strict;

use Rose::DB;

use base 'Class::DBI';

our $DB;

sub refresh
{
  no strict;
  no warnings 'redefine';
  *Ima::DBI::_mk_db_closure = sub 
  {
    my ( $class, @connection ) = @_;
    my $dbh;
    return sub 
    {
      unless ( $dbh && $dbh->FETCH('Active') && $dbh->ping )
      {
        my $db = Rose::DB->new;
        $db->connect_option( RootClass => 'DBIx::ContextualFetch' );
        $dbh = $db->retain_dbh;
      }
      return $dbh;
    };
  };


  $DB = Rose::DB->new;
  __PACKAGE__->connection($DB->dsn, $DB->username, $DB->password, scalar $DB->connect_options);
}

1;