| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package Catalyst::Model::CDBI; | 
| 2 |  |  |  |  |  |  |  | 
| 3 |  |  |  |  |  |  | # work around CDBI being incompatible with C3 mro, due to both Ima::DBI and Class::DBI::__::Base | 
| 4 |  |  |  |  |  |  | # inheriting from Class::Data::Inheritable in an inconsistent order. | 
| 5 |  |  |  |  |  |  | BEGIN { | 
| 6 | 1 |  |  | 1 |  | 53370 | require Class::DBI; | 
| 7 | 1 |  |  |  |  | 234091 | @Class::DBI::__::Base::ISA = grep { $_ ne 'Class::Data::Inheritable' } @Class::DBI::__::Base::ISA; | 
|  | 3 |  |  |  |  | 81 |  | 
| 8 |  |  |  |  |  |  | } | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 1 |  |  | 1 |  | 11 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 36 |  | 
| 11 | 1 |  |  | 1 |  | 5 | use base qw/Catalyst::Component Class::DBI/; | 
|  | 1 |  |  |  |  | 8 |  | 
|  | 1 |  |  |  |  | 1184 |  | 
| 12 |  |  |  |  |  |  | use MRO::Compat; | 
| 13 |  |  |  |  |  |  | use Class::DBI::Loader; | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | our $VERSION = '0.12'; | 
| 16 |  |  |  |  |  |  |  | 
| 17 |  |  |  |  |  |  | __PACKAGE__->mk_accessors('loader'); | 
| 18 |  |  |  |  |  |  |  | 
| 19 |  |  |  |  |  |  | =head1 NAME | 
| 20 |  |  |  |  |  |  |  | 
| 21 |  |  |  |  |  |  | Catalyst::Model::CDBI - [DEPRECATED] CDBI Model Class | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 24 |  |  |  |  |  |  |  | 
| 25 |  |  |  |  |  |  | # use the helper | 
| 26 |  |  |  |  |  |  | create model CDBI CDBI dsn user password | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | # lib/MyApp/Model/CDBI.pm | 
| 29 |  |  |  |  |  |  | package MyApp::Model::CDBI; | 
| 30 |  |  |  |  |  |  |  | 
| 31 |  |  |  |  |  |  | use base 'Catalyst::Model::CDBI'; | 
| 32 |  |  |  |  |  |  |  | 
| 33 |  |  |  |  |  |  | __PACKAGE__->config( | 
| 34 |  |  |  |  |  |  | dsn           => 'dbi:Pg:dbname=myapp', | 
| 35 |  |  |  |  |  |  | password      => '', | 
| 36 |  |  |  |  |  |  | user          => 'postgres', | 
| 37 |  |  |  |  |  |  | options       => { AutoCommit => 1 }, | 
| 38 |  |  |  |  |  |  | relationships => 1 | 
| 39 |  |  |  |  |  |  | ); | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | 1; | 
| 42 |  |  |  |  |  |  |  | 
| 43 |  |  |  |  |  |  | # As object method | 
| 44 |  |  |  |  |  |  | $c->comp('MyApp::Model::CDBI::Table')->search(...); | 
| 45 |  |  |  |  |  |  |  | 
| 46 |  |  |  |  |  |  | # As class method | 
| 47 |  |  |  |  |  |  | MyApp::Model::CDBI::Table->search(...); | 
| 48 |  |  |  |  |  |  |  | 
| 49 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 50 |  |  |  |  |  |  |  | 
| 51 |  |  |  |  |  |  | This is the C<Class::DBI> model class. It's built on top of | 
| 52 |  |  |  |  |  |  | C<Class::DBI::Loader>. C<Class::DBI> is generally not used for new | 
| 53 |  |  |  |  |  |  | applications, with C<DBIx::Class> being preferred instead. As such | 
| 54 |  |  |  |  |  |  | this model is deprecated and (mostly) unmaintained. | 
| 55 |  |  |  |  |  |  |  | 
| 56 |  |  |  |  |  |  | It is preserved here for older applications which still need it for | 
| 57 |  |  |  |  |  |  | backwards compatibility. | 
| 58 |  |  |  |  |  |  |  | 
| 59 |  |  |  |  |  |  | =head2 new | 
| 60 |  |  |  |  |  |  |  | 
| 61 |  |  |  |  |  |  | Initializes Class::DBI::Loader and loads classes using the class | 
| 62 |  |  |  |  |  |  | config. Also attempts to borg all the classes. | 
| 63 |  |  |  |  |  |  |  | 
| 64 |  |  |  |  |  |  | =cut | 
| 65 |  |  |  |  |  |  |  | 
| 66 |  |  |  |  |  |  | sub new { | 
| 67 |  |  |  |  |  |  | my $class = shift; | 
| 68 |  |  |  |  |  |  | my $self  = $class->next::method( @_ ); | 
| 69 |  |  |  |  |  |  | my $c     = shift; | 
| 70 |  |  |  |  |  |  | $self->{namespace}               ||= ref $self; | 
| 71 |  |  |  |  |  |  | $self->{additional_base_classes} ||= (); | 
| 72 |  |  |  |  |  |  | push @{ $self->{additional_base_classes} }, ref $self; | 
| 73 |  |  |  |  |  |  | eval { $self->loader( Class::DBI::Loader->new(%$self) ) }; | 
| 74 |  |  |  |  |  |  | if ($@) { | 
| 75 |  |  |  |  |  |  | Catalyst::Exception->throw( message => $@ ); | 
| 76 |  |  |  |  |  |  | } | 
| 77 |  |  |  |  |  |  | else { | 
| 78 |  |  |  |  |  |  | $c->log->debug( | 
| 79 |  |  |  |  |  |  | 'Loaded tables "' . join( ' ', $self->loader->tables ) . '"' ) | 
| 80 |  |  |  |  |  |  | if $c->debug; | 
| 81 |  |  |  |  |  |  | } | 
| 82 |  |  |  |  |  |  | for my $class ( $self->loader->classes ) { | 
| 83 |  |  |  |  |  |  | $class->autoupdate(1); | 
| 84 |  |  |  |  |  |  | $c->components->{$class} ||= bless {%$self}, $class; | 
| 85 |  |  |  |  |  |  | no strict 'refs'; | 
| 86 |  |  |  |  |  |  | *{"$class\::new"} = sub { bless {%$self}, $class }; | 
| 87 |  |  |  |  |  |  | } | 
| 88 |  |  |  |  |  |  | return $self; | 
| 89 |  |  |  |  |  |  | } | 
| 90 |  |  |  |  |  |  |  | 
| 91 |  |  |  |  |  |  | =head1 SEE ALSO | 
| 92 |  |  |  |  |  |  |  | 
| 93 |  |  |  |  |  |  | L<Catalyst>, L<Class::DBI> L<Class::DBI::Loader> | 
| 94 |  |  |  |  |  |  |  | 
| 95 |  |  |  |  |  |  | =head1 AUTHOR | 
| 96 |  |  |  |  |  |  |  | 
| 97 |  |  |  |  |  |  | Sebastian Riedel, C<sri@cpan.org> | 
| 98 |  |  |  |  |  |  |  | 
| 99 |  |  |  |  |  |  | =head1 CONTRIBUTORS | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | mst: Matt S Trout C<mst@shadowcat.co.uk> | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | Arathorn: Matthew Hodgson C<matthew@arasphere.net> | 
| 104 |  |  |  |  |  |  |  | 
| 105 |  |  |  |  |  |  | =head1 COPYRIGHT | 
| 106 |  |  |  |  |  |  |  | 
| 107 |  |  |  |  |  |  | Copyright (c) 2005 - 2010 the Catalyst::Model::CDBI L</AUTHOR> and | 
| 108 |  |  |  |  |  |  | L</CONTRIBUTORS> as listed above. | 
| 109 |  |  |  |  |  |  |  | 
| 110 |  |  |  |  |  |  | This program is free software, you can redistribute it and/or modify it | 
| 111 |  |  |  |  |  |  | under the same terms as Perl itself. | 
| 112 |  |  |  |  |  |  |  | 
| 113 |  |  |  |  |  |  | =cut | 
| 114 |  |  |  |  |  |  |  | 
| 115 |  |  |  |  |  |  | 1; |