98ca586eb7f3de8a15e2cd159881fe01d72640b4
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class / Storage / DBI / ODBC.pm
1 package DBIx::Class::Storage::DBI::ODBC;
2 use strict;
3 use warnings;
4
5 use base qw/DBIx::Class::Storage::DBI/;
6 use mro 'c3';
7 use Try::Tiny;
8
9 sub _rebless {
10     my ($self) = @_;
11
12     my $caught;
13     my $dbtype;
14     try { $self->_get_dbh->get_info(17) }
15     catch { $caught = 1 };
16
17     unless ( $caught ) {
18         # Translate the backend name into a perl identifier
19         $dbtype =~ s/\W/_/gi;
20         my $subclass = "DBIx::Class::Storage::DBI::ODBC::${dbtype}";
21         if ($self->load_optional_class($subclass) && !$self->isa($subclass)) {
22             bless $self, $subclass;
23             $self->_rebless;
24         }
25     }
26 }
27
28 1;
29
30 =head1 NAME
31
32 DBIx::Class::Storage::DBI::ODBC - Base class for ODBC drivers
33
34 =head1 DESCRIPTION
35
36 This class simply provides a mechanism for discovering and loading a sub-class
37 for a specific ODBC backend.  It should be transparent to the user.
38
39 =head1 AUTHORS
40
41 Marc Mims C<< <marc@questright.com> >>
42
43 =head1 LICENSE
44
45 You may distribute this code under the same terms as Perl itself.
46
47 =cut