1DBIx::Class::Manual::CoUmspeorneCnotn(t3r)ibuted Perl DoDcBuImxe:n:tCaltaisosn::Manual::Component(3)
2
3
4

NAME

6       DBIx::Class::Manual::Component - Developing DBIx::Class Components
7

WHAT IS A COMPONENT

9       A component is a module that can be added in to your DBIx::Class
10       classes to provide extra functionality. A good example is the PK::Auto
11       component which automatically retrieves primary keys that the database
12       itself creates, after the insert has happened.
13

USING

15       Components are loaded using the load_components() method within your
16       DBIx::Class classes.
17
18         package My::Thing;
19         use base qw( DBIx::Class::Core );
20         __PACKAGE__->load_components(qw/InflateColumn::DateTime TimeStamp/);
21
22       Generally you do not want to specify the full package name of a
23       component, instead take off the DBIx::Class:: part of it and just
24       include the rest.  If you do want to load a component outside of the
25       normal namespace you can do so by prepending the component name with a
26       +.
27
28         __PACKAGE__->load_components(qw/ +My::Component /);
29
30       Once a component is loaded all of it's methods, or otherwise, that it
31       provides will be available in your class.
32
33       The order in which is you load the components may be very important,
34       depending on the component. If you are not sure, then read the docs for
35       the components you are using and see if they mention anything about the
36       order in which you should load them.
37

CREATING COMPONENTS

39       Making your own component is very easy.
40
41         package DBIx::Class::MyComp;
42         use base qw(DBIx::Class);
43         # Create methods, accessors, load other components, etc.
44         1;
45
46       When a component is loaded it is included in the calling class'
47       inheritance chain using Class::C3.  As well as providing custom utility
48       methods, a component may also override methods provided by other core
49       components, like DBIx::Class::Row and others.  For example, you could
50       override the insert and delete methods.
51
52         sub insert {
53           my $self = shift;
54           # Do stuff with $self, like set default values.
55           return $self->next::method( @_ );
56         }
57
58         sub delete {
59           my $self = shift;
60           # Do stuff with $self.
61           return $self->next::method( @_ );
62         }
63
64       Now, the order that a component is loaded is very important.
65       Components that are loaded first are the first ones in the inheritance
66       stack.  So, if you override insert() but the DBIx::Class::Row component
67       is loaded first then your insert() will never be called, since the
68       DBIx::Class::Row insert() will be called first.  If you are unsure as
69       to why a given method is not being called try printing out the
70       Class::C3 inheritance stack.
71
72         print join ', ' => Class::C3::calculateMRO('YourClass::Name');
73
74       Check out the Class::C3 docs for more information about inheritance.
75

EXISTING COMPONENTS

77   Extra
78       These components provide extra functionality beyond basic functionality
79       that you can't live without.
80
81       DBIx::Class::Serialize::Storable - Hooks for Storable freeze/thaw.
82
83       DBIx::Class::CDBICompat - Class::DBI Compatibility layer.
84
85       DBIx::Class::FormTools - Build forms with multiple interconnected
86       objects.
87
88       DBIx::Class::HTMLWidget - Like FromForm but with DBIx::Class and
89       HTML::Widget.
90
91       DBIx::Class::Ordered - Modify the position of objects in an ordered
92       list.
93
94       DBIx::Class::PK::Auto - Retrieve automatically created primary keys
95       upon insert.
96
97       DBIx::Class::QueriesTime - Display the amount of time it takes to run
98       queries.
99
100       DBIx::Class::RandomStringColumns - Declare virtual columns that return
101       random strings.
102
103       DBIx::Class::UTF8Columns - Force UTF8 (Unicode) flag on columns.
104
105       DBIx::Class::UUIDColumns - Implicit UUID columns.
106
107       DBIx::Class::WebForm - CRUD methods.
108
109   Experimental
110       These components are under development, their interfaces may change,
111       they may not work, etc.  So, use them if you want, but be warned.
112
113       DBIx::Class::Validation - Validate all data before submitting to your
114       database.
115
116   Core
117       These are the components that all, or nearly all, people will use
118       without even knowing it.  These components provide most of DBIx::Class'
119       functionality.
120
121       DBIx::Class::Core - Loads various components that "most people" would
122       want.
123
124       DBIx::Class::AccessorGroup - Lets you build groups of accessors.
125
126       DBIx::Class::DB - Non-recommended classdata schema component.
127
128       DBIx::Class::InflateColumn - Automatically create objects from column
129       data.
130
131       DBIx::Class::PK - This class contains methods for handling primary keys
132       and methods depending on them.
133
134       DBIx::Class::Relationship - Inter-table relationships.
135
136       DBIx::Class::ResultSourceProxy::Table - Provides a classdata table
137       object and method proxies.
138
139       DBIx::Class::Row - Basic row methods.
140

SEE ALSO

142       DBIx::Class::Manual::Cookbook
143

AUTHOR

145       Aran Clary Deltac <bluefeet@cpan.org>
146
147
148
149perl v5.12.0                      2010-05-12 DBIx::Class::Manual::Component(3)
Impressum