trivial optimization to MODIFY_CODE_ATTRIBUTES
[dbsrgits/DBIx-Class.git] / lib / DBIx / Class.pm
1 package DBIx::Class;
2
3 use strict;
4 use warnings;
5
6 use vars qw($VERSION);
7 use base qw/DBIx::Class::Componentised Class::Data::Accessor/;
8
9 sub mk_classdata { shift->mk_classaccessor(@_); }
10 sub component_base_class { 'DBIx::Class' }
11
12 # Always remember to do all digits for the version even if they're 0
13 # i.e. first release of 0.XX *must* be 0.XX000. This avoids fBSD ports
14 # brain damage and presumably various other packaging systems too
15
16 $VERSION = '0.05999_04';
17
18 sub MODIFY_CODE_ATTRIBUTES {
19     my ($class,$code,@attrs) = @_;
20     $class->mk_classdata('__attr_cache' => {}) unless $class->can('__attr_cache');
21     $class->__attr_cache->{$code} = [@attrs];
22     return ();
23 }
24
25 sub _attr_cache {
26     my $self = shift;
27     my $cache = $self->can('__attr_cache') ? $self->__attr_cache : {};
28     my $rest = eval { $self->next::method };
29     return $@ ? $cache : { %$cache, %$rest };
30 }
31
32 1;
33
34 =head1 NAME 
35
36 DBIx::Class - Extensible and flexible object <-> relational mapper.
37
38 =head1 SYNOPSIS
39
40 =head1 DESCRIPTION
41
42 This is an SQL to OO mapper, inspired by the L<Class::DBI> framework, 
43 and meant to support compability with it, while restructuring the 
44 internals and making it possible to support some new features like 
45 self-joins, distinct, group bys and more.
46
47 This project is still at an early stage, so the maintainers don't make
48 any absolute promise that full backwards-compatibility will be supported;
49 however, if we can without compromising the improvements we're trying to
50 make, we will, and any non-compatible changes will merit a full justification
51 on the mailing list and a CPAN developer release for people to test against.
52
53 The community can be found via -
54
55   Mailing list: http://lists.rawmode.org/mailman/listinfo/dbix-class/
56
57   SVN: http://dev.catalyst.perl.org/repos/bast/trunk/DBIx-Class/
58
59   Wiki: http://dbix-class.shadowcatsystems.co.uk/
60
61   IRC: irc.perl.org#dbix-class
62
63 =head1 QUICKSTART
64
65 If you're using L<Class::DBI>, and want an easy and fast way of migrating to
66 DBIx::Class, take a look at L<DBIx::Class::CDBICompat>.
67
68 There are two ways of using DBIx::Class, the "simple" way and the "schema" way.
69 The "simple" way of using DBIx::Class needs less classes than the "schema"
70 way but doesn't give you the ability to easily use different database connections.
71
72 Some examples where different database connections are useful are:
73
74 different users with different rights
75 different databases with the same schema.
76
77 =head2 Simple
78
79 First you need to create a base class which all other classes will inherit from.
80 See L<DBIx::Class::DB> for information on how to do this.
81
82 Then you need to create a class for every table you want to use with DBIx::Class.
83 See L<DBIx::Class::Table> for information on how to do this.
84
85 =head2 Schema
86
87 With this approach, the table classes inherit directly from DBIx::Class::Core,
88 although it might be a good idea to create a "parent" class for all table
89 classes that inherits from DBIx::Class::Core and adds additional methods
90 needed by all table classes, e.g. reading a config file or loading auto primary
91 key support.
92
93 Look at L<DBIx::Class::Schema> for information on how to do this.
94
95 If you need more help, check out the introduction in the 
96 manual below.
97
98 =head1 SEE ALSO
99
100 =over 4
101
102 =item L<DBIx::Class::Core> - DBIC Core Classes
103
104 =item L<DBIx::Class::Manual> - User's manual
105
106 =item L<DBIx::Class::CDBICompat> - L<Class::DBI> Compat layer
107
108 =item L<DBIx::Class::Schema>
109
110 =item L<DBIx::Class::ResultSet>
111
112 =item L<DBIx::Class::ResultSource>
113
114 =item L<DBIx::Class::Row> - row-level methods
115
116 =item L<DBIx::Class::PK> - primary key methods
117
118 =item L<DBIx::Class::Relationship> - relationships between tables
119
120 =back
121
122 =head1 AUTHOR
123
124 Matt S. Trout <mst@shadowcatsystems.co.uk>
125
126 =head1 CONTRIBUTORS
127
128 Andy Grundman <andy@hybridized.org>
129
130 Brian Cassidy <bricas@cpan.org>
131
132 Dan Kubb <dan.kubb-cpan@onautopilot.com>
133
134 Dan Sully <daniel@cpan.org>
135
136 David Kamholz <dkamholz@cpan.org>
137
138 Jules Bean
139
140 Marcus Ramberg <mramberg@cpan.org>
141
142 Paul Makepeace
143
144 CL Kao
145
146 Jess Robinson
147
148 Marcus Ramberg
149
150 Will Hawes
151
152 Todd Lipcon
153
154 Daniel Westermann-Clark <danieltwc@cpan.org>
155
156 Alexander Hartmaier <alex_hartmaier@hotmail.com>
157
158 Zbigniew Lukasiak
159
160 Nigel Metheringham <nigelm@cpan.org>
161
162 Jesper Krogh
163
164 Brandon Black
165
166 Christopher H. Laco
167
168 Scotty Allen <scotty@scottyallen.com>
169
170 sc_
171
172 Robert Sedlacek <phaylon@dunkelheit.at
173
174 Justin Guenther <guentherj@agr.gc.ca>
175
176 Daisuke Murase <typester@cpan.org>
177
178 Scott McWhirter (konobi)
179
180 =head1 LICENSE
181
182 You may distribute this code under the same terms as Perl itself.
183
184 =cut
185