Don't inject self into base :)
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class.pm
CommitLineData
ea2e61bf 1package DBIx::Class;
2
5d283305 3use strict;
4use warnings;
5
5d283305 6use vars qw($VERSION);
126042ee 7use base;
5d283305 8
9$VERSION = '0.01';
10
126042ee 11sub load_components {
12 my $class = shift;
8b445e33 13 my @comp = map { "DBIx::Class::$_" } grep { $_ !~ /^#/ } @_;
55e2d745 14 $class->_load_components(@comp);
15}
16
17sub load_own_components {
18 my $class = shift;
19 my @comp = map { "${class}::$_" } grep { $_ !~ /^#/ } @_;
20 $class->_load_components(@comp);
21}
22
23sub _load_components {
24 my ($class, @comp) = @_;
126042ee 25 foreach my $comp (@comp) {
26 eval "use $comp";
27 die $@ if $@;
28 }
29 no strict 'refs';
30 unshift(@{"${class}::ISA"}, @comp);
31}
32
ea2e61bf 331;
34d52be2 34
35=head1 NAME
36
37DBIx::Class - Because the brain is a terrible thing to waste.
38
39=head1 SYNOPSIS
40
41=head1 DESCRIPTION
42
43This is a sql to oop mapper, inspired by the L<Class::DBI> framework,
44and meant to support compability with it, while restructuring the
45insides, and making it possible to support some new features like
46self-joins, distinct, group bys and more.
47
39fe0e65 48=head1 QUICKSTART
49
50If you're using Class::DBI, replacing
51
52use base qw/Class::DBI/;
53
54with
55
126042ee 56use base qw/DBIx::Class/;
a02675cd 57__PACKAGE__->load_components(qw/CDBICompat Core DB/);
39fe0e65 58
59will probably get you started.
60
61If you're using AUTO_INCREMENT for your primary columns, you'll also want
126042ee 62yo load the approriate PK::Auto subclass - e.g.
63
a02675cd 64__PACKAGE__->load_components(qw/CDBICompat PK::Auto::SQLite Core DB/);
126042ee 65
66(with is what ::Test::SQLite does to present the Class::DBI::Test::SQLite
67interface)
39fe0e65 68
69If you fancy playing around with DBIx::Class from scratch, then read the docs
70for ::Table and ::Relationship,
71
72use base qw/DBIx::Class/;
a02675cd 73__PACKAGE__->load_components(qw/Core DB/);
39fe0e65 74
75and have a look at t/lib/DBICTest.pm for a brief example.
76
34d52be2 77=head1 AUTHORS
78
79Matt S. Trout <perl-stuff@trout.me.uk>
80
81=head1 LICENSE
82
83You may distribute this code under the same terms as Perl itself.
84
85=cut
86