| 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 | 1 | ▶ | BEGIN { | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | 1 | require Class::DBI; | |||||||||||||||||||
| 7 | 1 | @Class::DBI::__::Base::ISA = grep { $_ ne 'Class::Data::Inheritable' } @Class::DBI::__::Base::ISA; | |||||||||||||||||||
| 8 | } | ||||||||||||||||||||
| 9 | |||||||||||||||||||||
| 10 | 1 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 11 | 1 | ▶ | use base qw/Catalyst::Component Class::DBI/; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 12 | 1 | ▶ | use MRO::Compat; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 13 | 1 | ▶ | use Class::DBI::Loader; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | 1 | our $VERSION = '0.12'; | |||||||||||||||||||
| 16 | |||||||||||||||||||||
| 17 | 1 | __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 | 0 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: not called CC=7 SCAR=37.9
Pod
documented
| |||||||||||||||||||||
| 67 | 0 | my $class = shift; | |||||||||||||||||||
| 68 | 0 | my $self = $class->next::method( @_ ); | |||||||||||||||||||
| 69 | 0 | my $c = shift; | |||||||||||||||||||
| 70 | 0 | ▶ | $self->{namespace} ||= ref $self; | ||||||||||||||||||
|
Condition0%0/3
$self->{"namespace"} ||= ref $self
MC/DC0%0/2
$self->{"namespace"} ||= ref $self
$self->{"namespace"}
ref $self
Truth table0%0/3
A ||= B
A= $self->{"namespace"}B= ref $self
| |||||||||||||||||||||
| 71 | 0 | ▶ | $self->{additional_base_classes} ||= (); | ||||||||||||||||||
|
Condition0%0/3
$self->{"additional_base_classes"} ||= ()
MC/DC0%0/2
$self->{"additional_base_classes"} ||= ()
$self->{"additional_base_classes"}
()
Truth table0%0/3
A ||= B
A= $self->{"additional_base_classes"}B= ()
| |||||||||||||||||||||
| 72 | 0 | push @{ $self->{additional_base_classes} }, ref $self; | |||||||||||||||||||
| 73 | 0 | eval { $self->loader( Class::DBI::Loader->new(%$self) ) }; | |||||||||||||||||||
| 74 | 0 | ▶ | if ($@) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 75 | 0 | Catalyst::Exception->throw( message => $@ ); | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | else { | ||||||||||||||||||||
| 78 | 0 | ▶ | $c->log->debug( | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 79 | 'Loaded tables "' . join( ' ', $self->loader->tables ) . '"' ) | ||||||||||||||||||||
| 80 | if $c->debug; | ||||||||||||||||||||
| 81 | } | ||||||||||||||||||||
| 82 | 0 | for my $class ( $self->loader->classes ) { | |||||||||||||||||||
| 83 | 0 | $class->autoupdate(1); | |||||||||||||||||||
| 84 | 0 | ▶ | $c->components->{$class} ||= bless {%$self}, $class; | ||||||||||||||||||
|
Condition0%0/2
$c->components->{$class} ||= bless({%$self}, $class)
MC/DC0%0/1
$c->components->{$class} ||= bless({%$self}, $class)
$c->components->{$class}
Truth table0%0/2
A
A= $c->components->{$class}
| |||||||||||||||||||||
| 85 | 1 | ▶ | no strict 'refs'; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 86 | 0 | ▶ | *{"$class\::new"} = sub { bless {%$self}, $class }; | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||
| 87 | } | ||||||||||||||||||||
| 88 | 0 | 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 | 1; | |||||||||||||||||||