aboutsummaryrefslogtreecommitdiffstats
path: root/old/Manual/Internals.pod
blob: 720608c0552c3cfcd885e15c8b4c408b25b7cb7d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
=head1 NAME

Reaction::Manual::Internals

=head2 Hacking on Reaction

=head3 What is a component?

=head3 What component types are there?

=head3 How do I create a new component?

=head3 How does it work with a database?

=head3 What about Moose?

L<Moose>

=head3 Type system

=head3 What Perl modules should I be familiar with, in order to hack on Reaction's
internals?

=over

=item L<Moose>

A complete modern object system for Perl 5.

=item L<aliased>

Use shorter package names, i.e., "X::Y::Z" as "Z".

=item L<Catalyst>

The MVC application framework Reaction uses.

=over

=item * L<Catalyst::Controller::BindLex>

=item * L<Catalyst::Model::DBIC::Schema>

=item * L<Catalyst::Plugin::ConfigLoader> 

=item * L<Catalyst::Plugin::I18N>

=item * L<Catalyst::Plugin::Static::Simple>

=item * L<Catalyst::View::TT>

=back

=item TT

Template Toolkit

=item L<Config::General> 

Generic config file module.

=item L<DBIx::Class> 

Object/Relational mapper.

=item L<DateTime>

=item L<DateTime::Format::MySQL>

=item L<Digest::MD5>

=item L<Email::MIME>

=item L<Email::MIME::Creator>

=item L<Email::Send>

=item L<Email::Valid>

=item L<SQL::Translator>

=item L<Test::Class>

=item L<Test::Memory::Cycle>

=item L<Time::ParseDate>

=back

=head3 Packages involved

=over

=item L<Reaction::Class>

Utility class, sets up to export a few methods that return parameters for use
within Moose's C<has> (as new parameters) in other packages. It also C<use>s
Moose itself.

The methods it injects are:

=over

=item set_or_lazy_build($field_name)

The attribute is required, if not provided beforehand the build_${name} method
will be called on the object when the attribute's getter is first called. If
the method does not exist, or returns undef, an error will be thrown.

=item set_or_lazy_fail()

The attribute is required, if not provided beforehand the 'lazy' parameter of
Moose will make it fail.

=item trigger_adopt()

Calls adopt_${type} after the attribute value is set to $type.

=item register_inc_entry()

Will mark the calling package as already included, using %INC.

=back

=item Reaction::InterfaceModel::Action

=item Reaction::InterfaceModel::Action::DBIC::ResultSet::Create;

=item Reaction::InterfaceModel::Action::DBIC::ActionReflector;

A method "adaptor" that creates the needed objects to support CRUD DBIC
actions. In the future the code could be moved to a class higher in the
hierarchy and only contain the operations to adapt.

Sample run:

Reaction::InterfaceModel::Action::DBIC::ActionReflector->reflect_actions_for(
Reaction::InterfaceModel::Action::DBIC::ActionReflector=HASH(0x93cb2f0) 
RTest::TestDB::Foo 
ComponentUI::Model::Action
)

Generates and evaluates:

package ComponentUI::Model::Action::DeleteFoo;
use Reaction::Class;
extends 'Reaction::InterfaceModel::Action::DBIC::Result::Delete';
package ComponentUI::Model::Action::UpdateFoo;
use Reaction::Class;
extends 'Reaction::InterfaceModel::Action::DBIC::Result::Update';
has 'baz_list' => (isa => 'ArrayRef', is => 'rw', set_or_lazy_fail('baz_list'), default => sub { [] }, valid_values => sub {
$_[0]->target_model
->result_source
->related_source('links_to_baz_list')
->related_source('baz')
->resultset;
});
has 'last_name' => (isa => 'NonEmptySimpleStr', is => 'rw', set_or_lazy_fail('last_name'));
has 'first_name' => (isa => 'NonEmptySimpleStr', is => 'rw', set_or_lazy_fail('first_name'));
package ComponentUI::Model::Action::CreateFoo;
use Reaction::Class;
extends 'Reaction::InterfaceModel::Action::DBIC::ResultSet::Create';
has 'baz_list' => (isa => 'ArrayRef', is => 'rw', set_or_lazy_fail('baz_list'), default => sub { [] }, valid_values => sub {
$_[0]->target_model
->result_source
->related_source('links_to_baz_list')
->related_source('baz')
->resultset;
});
has 'last_name' => (isa => 'NonEmptySimpleStr', is => 'rw', set_or_lazy_fail('last_name'));
has 'first_name' => (isa => 'NonEmptySimpleStr', is => 'rw', set_or_lazy_fail('first_name'));

=item Reaction::InterfaceModel::Action::DBIC::Result::Delete

=item Reaction::InterfaceModel::Action::DBIC::Result::Update

=item Reaction::InterfaceModel::Action::DBIC::User::ResetPassword

=item Reaction::InterfaceModel::Action::DBIC::User::Role::SetPassword

=item Reaction::InterfaceModel::Action::DBIC::User::ChangePassword

=item Reaction::InterfaceModel::Action::User::ResetPassword

=item Reaction::InterfaceModel::Action::User::ChangePassword

=item Reaction::InterfaceModel::Action::User::SetPassword

=item Reaction::Meta::InterfaceModel::Action::ParameterAttribute

=item Reaction::Meta::InterfaceModel::Action::Class

=item Reaction::Types::Email

=item Reaction::Types::Core

=item Reaction::Types::DateTime

=item Reaction::Types::File

=item Reaction::Types::DBIC

=item Reaction::UI::ViewPort::ListView

=item Reaction::UI::ViewPort::Field::Text

=item Reaction::UI::ViewPort::Field::ChooseMany

=item Reaction::UI::ViewPort::Field::String

=item Reaction::UI::ViewPort::Field::Number

=item Reaction::UI::ViewPort::Field::HiddenArray

=item Reaction::UI::ViewPort::Field::DateTime

=item Reaction::UI::ViewPort::Field::File

=item Reaction::UI::ViewPort::Field::ChooseOne

=item Reaction::UI::ViewPort::Field::Password

=item Reaction::UI::ViewPort::ActionForm

=item Reaction::UI::ViewPort::Field

=item Reaction::UI::FocusStack

=item Reaction::UI::RootController

=item Reaction::UI::Window

=item Reaction::UI::Renderer::XHTML

=item Reaction::UI::ViewPort

=item Reaction::UI::CRUDController

=item Reaction::UI::Controller

=back

=head3 Remarks about POD

Don't use C<=over N>. POD assumes that the indent level is 4 if you leave
it out. Most POD renderers ignore your indent level anyway.

=head2 UNSORTED

Packages involved

t/lib/Rtest/TestDB*: TestDB DBIC declarations.
t/lib/RTest/TestDB.pm: does DBIC populate for t/.
t/lib/RTest/UI/ XXX

Reaction::Test::WithDB;
Reaction::Test;
Reaction::Test::Mock::Context;
Reaction::Test::Mock::Request;
Reaction::Test::Mock::Response;

=head1 AUTHORS

See L<Reaction::Class> for authors.

=head1 LICENSE

See L<Reaction::Class> for the license.

=cut