hyperactiveform 0.1.0 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/README.md +25 -1
- data/docs/HyperActiveForm/Base.html +884 -0
- data/docs/HyperActiveForm/CancelFormSubmit.html +124 -0
- data/docs/HyperActiveForm/FormDidNotSubmitError.html +124 -0
- data/docs/HyperActiveForm/Generators/InstallGenerator.html +199 -0
- data/docs/HyperActiveForm/Generators.html +115 -0
- data/docs/HyperActiveForm.html +135 -0
- data/docs/_index.html +182 -0
- data/docs/class_list.html +54 -0
- data/docs/css/common.css +1 -0
- data/docs/css/full_list.css +58 -0
- data/docs/css/style.css +503 -0
- data/docs/file.README.html +271 -0
- data/docs/file_list.html +59 -0
- data/docs/frames.html +22 -0
- data/docs/index.html +271 -0
- data/docs/js/app.js +344 -0
- data/docs/js/full_list.js +242 -0
- data/docs/js/jquery.js +4 -0
- data/docs/method_list.html +126 -0
- data/docs/top-level-namespace.html +110 -0
- data/examples/basic.md +85 -0
- data/lib/hyper_active_form/base.rb +43 -5
- data/lib/hyper_active_form/version.rb +1 -1
- metadata +37 -2
@@ -0,0 +1,884 @@
|
|
1
|
+
<!DOCTYPE html>
|
2
|
+
<html>
|
3
|
+
<head>
|
4
|
+
<meta charset="utf-8">
|
5
|
+
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
|
+
<title>
|
7
|
+
Class: HyperActiveForm::Base
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.37
|
10
|
+
|
11
|
+
</title>
|
12
|
+
|
13
|
+
<link rel="stylesheet" href="../css/style.css" type="text/css" />
|
14
|
+
|
15
|
+
<link rel="stylesheet" href="../css/common.css" type="text/css" />
|
16
|
+
|
17
|
+
<script type="text/javascript">
|
18
|
+
pathId = "HyperActiveForm::Base";
|
19
|
+
relpath = '../';
|
20
|
+
</script>
|
21
|
+
|
22
|
+
|
23
|
+
<script type="text/javascript" charset="utf-8" src="../js/jquery.js"></script>
|
24
|
+
|
25
|
+
<script type="text/javascript" charset="utf-8" src="../js/app.js"></script>
|
26
|
+
|
27
|
+
|
28
|
+
</head>
|
29
|
+
<body>
|
30
|
+
<div class="nav_wrap">
|
31
|
+
<iframe id="nav" src="../class_list.html?1"></iframe>
|
32
|
+
<div id="resizer"></div>
|
33
|
+
</div>
|
34
|
+
|
35
|
+
<div id="main" tabindex="-1">
|
36
|
+
<div id="header">
|
37
|
+
<div id="menu">
|
38
|
+
|
39
|
+
<a href="../_index.html">Index (B)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../HyperActiveForm.html" title="HyperActiveForm (module)">HyperActiveForm</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">Base</span>
|
43
|
+
|
44
|
+
</div>
|
45
|
+
|
46
|
+
<div id="search">
|
47
|
+
|
48
|
+
<a class="full_list_link" id="class_list_link"
|
49
|
+
href="../class_list.html">
|
50
|
+
|
51
|
+
<svg width="24" height="24">
|
52
|
+
<rect x="0" y="4" width="24" height="4" rx="1" ry="1"></rect>
|
53
|
+
<rect x="0" y="12" width="24" height="4" rx="1" ry="1"></rect>
|
54
|
+
<rect x="0" y="20" width="24" height="4" rx="1" ry="1"></rect>
|
55
|
+
</svg>
|
56
|
+
</a>
|
57
|
+
|
58
|
+
</div>
|
59
|
+
<div class="clear"></div>
|
60
|
+
</div>
|
61
|
+
|
62
|
+
<div id="content"><h1>Class: HyperActiveForm::Base
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">Object</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">HyperActiveForm::Base</li>
|
78
|
+
|
79
|
+
</ul>
|
80
|
+
<a href="#" class="inheritanceTree">show all</a>
|
81
|
+
|
82
|
+
</dd>
|
83
|
+
</dl>
|
84
|
+
|
85
|
+
|
86
|
+
|
87
|
+
|
88
|
+
<dl>
|
89
|
+
<dt>Extended by:</dt>
|
90
|
+
<dd>ActiveModel::Callbacks</dd>
|
91
|
+
</dl>
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
<dl>
|
96
|
+
<dt>Includes:</dt>
|
97
|
+
<dd>ActiveModel::Attributes, ActiveModel::Model, ActiveModel::Validations</dd>
|
98
|
+
</dl>
|
99
|
+
|
100
|
+
|
101
|
+
|
102
|
+
|
103
|
+
|
104
|
+
|
105
|
+
<dl>
|
106
|
+
<dt>Defined in:</dt>
|
107
|
+
<dd>lib/hyper_active_form/base.rb</dd>
|
108
|
+
</dl>
|
109
|
+
|
110
|
+
</div>
|
111
|
+
|
112
|
+
<h2>Overview</h2><div class="docstring">
|
113
|
+
<div class="discussion">
|
114
|
+
|
115
|
+
<p>Base class for HyperActiveForm objects</p>
|
116
|
+
|
117
|
+
<p>HyperActiveForm objects are simple ActiveModel objects that encapsulate form logic and validations. They are designed to be subclassed and customized to fit the needs of your application.</p>
|
118
|
+
|
119
|
+
|
120
|
+
</div>
|
121
|
+
</div>
|
122
|
+
<div class="tags">
|
123
|
+
|
124
|
+
|
125
|
+
</div>
|
126
|
+
|
127
|
+
|
128
|
+
|
129
|
+
|
130
|
+
|
131
|
+
|
132
|
+
|
133
|
+
<h2>
|
134
|
+
Class Method Summary
|
135
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
136
|
+
</h2>
|
137
|
+
|
138
|
+
<ul class="summary">
|
139
|
+
|
140
|
+
<li class="public ">
|
141
|
+
<span class="summary_signature">
|
142
|
+
|
143
|
+
<a href="#proxy_for-class_method" title="proxy_for (class method)">.<strong>proxy_for</strong>(klass, object) ⇒ Object </a>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
</span>
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
|
154
|
+
|
155
|
+
|
156
|
+
|
157
|
+
<span class="summary_desc"><div class='inline'>
|
158
|
+
<p>Defines to which object the form should delegate the active model methods This is useful so ‘form_for`/`form_with` can automatically deduce the url and method to use.</p>
|
159
|
+
</div></span>
|
160
|
+
|
161
|
+
</li>
|
162
|
+
|
163
|
+
|
164
|
+
</ul>
|
165
|
+
|
166
|
+
<h2>
|
167
|
+
Instance Method Summary
|
168
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
169
|
+
</h2>
|
170
|
+
|
171
|
+
<ul class="summary">
|
172
|
+
|
173
|
+
<li class="public ">
|
174
|
+
<span class="summary_signature">
|
175
|
+
|
176
|
+
<a href="#add_errors_from-instance_method" title="#add_errors_from (instance method)">#<strong>add_errors_from</strong>(model) ⇒ Object </a>
|
177
|
+
|
178
|
+
|
179
|
+
|
180
|
+
</span>
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
|
189
|
+
|
190
|
+
<span class="summary_desc"><div class='inline'>
|
191
|
+
<p>Adds the errors from a model to the form.</p>
|
192
|
+
</div></span>
|
193
|
+
|
194
|
+
</li>
|
195
|
+
|
196
|
+
|
197
|
+
<li class="public ">
|
198
|
+
<span class="summary_signature">
|
199
|
+
|
200
|
+
<a href="#assign_form_attributes-instance_method" title="#assign_form_attributes (instance method)">#<strong>assign_form_attributes</strong>(params) ⇒ Object </a>
|
201
|
+
|
202
|
+
|
203
|
+
|
204
|
+
</span>
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
|
213
|
+
|
214
|
+
<span class="summary_desc"><div class='inline'>
|
215
|
+
<p>Assigns the attributes of the form from the params This method is called by the ‘submit` method, but can also be called directly if you need to assign the attributes without submitting the form for example if you want to refresh the form with new data.</p>
|
216
|
+
</div></span>
|
217
|
+
|
218
|
+
</li>
|
219
|
+
|
220
|
+
|
221
|
+
<li class="public ">
|
222
|
+
<span class="summary_signature">
|
223
|
+
|
224
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong> ⇒ Base </a>
|
225
|
+
|
226
|
+
|
227
|
+
|
228
|
+
</span>
|
229
|
+
|
230
|
+
|
231
|
+
<span class="note title constructor">constructor</span>
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
|
238
|
+
|
239
|
+
|
240
|
+
<span class="summary_desc"><div class='inline'>
|
241
|
+
<p>A new instance of Base.</p>
|
242
|
+
</div></span>
|
243
|
+
|
244
|
+
</li>
|
245
|
+
|
246
|
+
|
247
|
+
<li class="public ">
|
248
|
+
<span class="summary_signature">
|
249
|
+
|
250
|
+
<a href="#perform-instance_method" title="#perform (instance method)">#<strong>perform</strong> ⇒ Object </a>
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
</span>
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
|
261
|
+
|
262
|
+
|
263
|
+
|
264
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
265
|
+
|
266
|
+
</li>
|
267
|
+
|
268
|
+
|
269
|
+
<li class="public ">
|
270
|
+
<span class="summary_signature">
|
271
|
+
|
272
|
+
<a href="#setup-instance_method" title="#setup (instance method)">#<strong>setup</strong> ⇒ Object </a>
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
</span>
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
|
286
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
287
|
+
|
288
|
+
</li>
|
289
|
+
|
290
|
+
|
291
|
+
<li class="public ">
|
292
|
+
<span class="summary_signature">
|
293
|
+
|
294
|
+
<a href="#submit-instance_method" title="#submit (instance method)">#<strong>submit</strong>(params) ⇒ Boolean </a>
|
295
|
+
|
296
|
+
|
297
|
+
|
298
|
+
</span>
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
|
307
|
+
|
308
|
+
<span class="summary_desc"><div class='inline'>
|
309
|
+
<p>Submits the form, assigning the attributes from the params, running validations and calling the ‘perform` method if the form is valid.</p>
|
310
|
+
</div></span>
|
311
|
+
|
312
|
+
</li>
|
313
|
+
|
314
|
+
|
315
|
+
<li class="public ">
|
316
|
+
<span class="summary_signature">
|
317
|
+
|
318
|
+
<a href="#submit!-instance_method" title="#submit! (instance method)">#<strong>submit!</strong>(params) ⇒ Boolean </a>
|
319
|
+
|
320
|
+
|
321
|
+
|
322
|
+
</span>
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
|
331
|
+
|
332
|
+
<span class="summary_desc"><div class='inline'>
|
333
|
+
<p>Same as ‘submit` but raises a `FormDidNotSubmitError` if the form is not valid.</p>
|
334
|
+
</div></span>
|
335
|
+
|
336
|
+
</li>
|
337
|
+
|
338
|
+
|
339
|
+
</ul>
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
<div id="constructor_details" class="method_details_list">
|
347
|
+
<h2>Constructor Details</h2>
|
348
|
+
|
349
|
+
<div class="method_details first">
|
350
|
+
<h3 class="signature first" id="initialize-instance_method">
|
351
|
+
|
352
|
+
#<strong>initialize</strong> ⇒ <tt><span class='object_link'><a href="" title="HyperActiveForm::Base (class)">Base</a></span></tt>
|
353
|
+
|
354
|
+
|
355
|
+
|
356
|
+
|
357
|
+
|
358
|
+
</h3><div class="docstring">
|
359
|
+
<div class="discussion">
|
360
|
+
|
361
|
+
<p>Returns a new instance of Base.</p>
|
362
|
+
|
363
|
+
|
364
|
+
</div>
|
365
|
+
</div>
|
366
|
+
<div class="tags">
|
367
|
+
|
368
|
+
|
369
|
+
</div><table class="source_code">
|
370
|
+
<tr>
|
371
|
+
<td>
|
372
|
+
<pre class="lines">
|
373
|
+
|
374
|
+
|
375
|
+
32
|
376
|
+
33
|
377
|
+
34
|
378
|
+
35</pre>
|
379
|
+
</td>
|
380
|
+
<td>
|
381
|
+
<pre class="code"><span class="info file"># File 'lib/hyper_active_form/base.rb', line 32</span>
|
382
|
+
|
383
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='op'>*</span><span class='comma'>,</span> <span class='op'>**</span><span class='rparen'>)</span>
|
384
|
+
<span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
385
|
+
<span class='id identifier rubyid_setup'>setup</span><span class='lparen'>(</span><span class='op'>*</span><span class='comma'>,</span> <span class='op'>**</span><span class='rparen'>)</span>
|
386
|
+
<span class='kw'>end</span></pre>
|
387
|
+
</td>
|
388
|
+
</tr>
|
389
|
+
</table>
|
390
|
+
</div>
|
391
|
+
|
392
|
+
</div>
|
393
|
+
|
394
|
+
|
395
|
+
<div id="class_method_details" class="method_details_list">
|
396
|
+
<h2>Class Method Details</h2>
|
397
|
+
|
398
|
+
|
399
|
+
<div class="method_details first">
|
400
|
+
<h3 class="signature first" id="proxy_for-class_method">
|
401
|
+
|
402
|
+
.<strong>proxy_for</strong>(klass, object) ⇒ <tt>Object</tt>
|
403
|
+
|
404
|
+
|
405
|
+
|
406
|
+
|
407
|
+
|
408
|
+
</h3><div class="docstring">
|
409
|
+
<div class="discussion">
|
410
|
+
|
411
|
+
<p>Defines to which object the form should delegate the active model methods This is useful so ‘form_for`/`form_with` can automatically deduce the url and method to use</p>
|
412
|
+
|
413
|
+
|
414
|
+
</div>
|
415
|
+
</div>
|
416
|
+
<div class="tags">
|
417
|
+
<p class="tag_title">Parameters:</p>
|
418
|
+
<ul class="param">
|
419
|
+
|
420
|
+
<li>
|
421
|
+
|
422
|
+
<span class='name'>klass</span>
|
423
|
+
|
424
|
+
|
425
|
+
<span class='type'>(<tt>Class</tt>)</span>
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
—
|
430
|
+
<div class='inline'>
|
431
|
+
<p>the class of the object to proxy</p>
|
432
|
+
</div>
|
433
|
+
|
434
|
+
</li>
|
435
|
+
|
436
|
+
<li>
|
437
|
+
|
438
|
+
<span class='name'>object</span>
|
439
|
+
|
440
|
+
|
441
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
442
|
+
|
443
|
+
|
444
|
+
|
445
|
+
—
|
446
|
+
<div class='inline'>
|
447
|
+
<p>where to delegate the object to, for example: ‘:@user`</p>
|
448
|
+
</div>
|
449
|
+
|
450
|
+
</li>
|
451
|
+
|
452
|
+
</ul>
|
453
|
+
|
454
|
+
|
455
|
+
</div><table class="source_code">
|
456
|
+
<tr>
|
457
|
+
<td>
|
458
|
+
<pre class="lines">
|
459
|
+
|
460
|
+
|
461
|
+
27
|
462
|
+
28
|
463
|
+
29
|
464
|
+
30</pre>
|
465
|
+
</td>
|
466
|
+
<td>
|
467
|
+
<pre class="code"><span class="info file"># File 'lib/hyper_active_form/base.rb', line 27</span>
|
468
|
+
|
469
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_proxy_for'>proxy_for</span><span class='lparen'>(</span><span class='id identifier rubyid_klass'>klass</span><span class='comma'>,</span> <span class='id identifier rubyid_object'>object</span><span class='rparen'>)</span>
|
470
|
+
<span class='id identifier rubyid_delegate'>delegate</span> <span class='symbol'>:new_record?</span><span class='comma'>,</span> <span class='symbol'>:persisted?</span><span class='comma'>,</span> <span class='symbol'>:id</span><span class='comma'>,</span> <span class='label'>to:</span> <span class='id identifier rubyid_object'>object</span>
|
471
|
+
<span class='id identifier rubyid_singleton_class'>singleton_class</span><span class='period'>.</span><span class='id identifier rubyid_delegate'>delegate</span> <span class='symbol'>:model_name</span><span class='comma'>,</span> <span class='label'>to:</span> <span class='id identifier rubyid_klass'>klass</span>
|
472
|
+
<span class='kw'>end</span></pre>
|
473
|
+
</td>
|
474
|
+
</tr>
|
475
|
+
</table>
|
476
|
+
</div>
|
477
|
+
|
478
|
+
</div>
|
479
|
+
|
480
|
+
<div id="instance_method_details" class="method_details_list">
|
481
|
+
<h2>Instance Method Details</h2>
|
482
|
+
|
483
|
+
|
484
|
+
<div class="method_details first">
|
485
|
+
<h3 class="signature first" id="add_errors_from-instance_method">
|
486
|
+
|
487
|
+
#<strong>add_errors_from</strong>(model) ⇒ <tt>Object</tt>
|
488
|
+
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
</h3><div class="docstring">
|
494
|
+
<div class="discussion">
|
495
|
+
|
496
|
+
<p>Adds the errors from a model to the form</p>
|
497
|
+
|
498
|
+
|
499
|
+
</div>
|
500
|
+
</div>
|
501
|
+
<div class="tags">
|
502
|
+
<p class="tag_title">Parameters:</p>
|
503
|
+
<ul class="param">
|
504
|
+
|
505
|
+
<li>
|
506
|
+
|
507
|
+
<span class='name'>model</span>
|
508
|
+
|
509
|
+
|
510
|
+
<span class='type'>(<tt>ActiveModel::Model</tt>)</span>
|
511
|
+
|
512
|
+
|
513
|
+
|
514
|
+
—
|
515
|
+
<div class='inline'>
|
516
|
+
<p>the model to add the errors from</p>
|
517
|
+
</div>
|
518
|
+
|
519
|
+
</li>
|
520
|
+
|
521
|
+
</ul>
|
522
|
+
|
523
|
+
|
524
|
+
</div><table class="source_code">
|
525
|
+
<tr>
|
526
|
+
<td>
|
527
|
+
<pre class="lines">
|
528
|
+
|
529
|
+
|
530
|
+
84
|
531
|
+
85
|
532
|
+
86
|
533
|
+
87
|
534
|
+
88
|
535
|
+
89
|
536
|
+
90</pre>
|
537
|
+
</td>
|
538
|
+
<td>
|
539
|
+
<pre class="code"><span class="info file"># File 'lib/hyper_active_form/base.rb', line 84</span>
|
540
|
+
|
541
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_add_errors_from'>add_errors_from</span><span class='lparen'>(</span><span class='id identifier rubyid_model'>model</span><span class='rparen'>)</span>
|
542
|
+
<span class='id identifier rubyid_model'>model</span><span class='period'>.</span><span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_error'>error</span><span class='op'>|</span>
|
543
|
+
<span class='const'>Array</span><span class='period'>.</span><span class='id identifier rubyid_wrap'>wrap</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_message'>message</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_e'>e</span><span class='op'>|</span> <span class='id identifier rubyid_errors'>errors</span><span class='period'>.</span><span class='id identifier rubyid_add'>add</span><span class='lparen'>(</span><span class='id identifier rubyid_error'>error</span><span class='period'>.</span><span class='id identifier rubyid_attribute'>attribute</span><span class='comma'>,</span> <span class='id identifier rubyid_e'>e</span><span class='rparen'>)</span> <span class='rbrace'>}</span>
|
544
|
+
<span class='kw'>end</span>
|
545
|
+
|
546
|
+
<span class='kw'>false</span>
|
547
|
+
<span class='kw'>end</span></pre>
|
548
|
+
</td>
|
549
|
+
</tr>
|
550
|
+
</table>
|
551
|
+
</div>
|
552
|
+
|
553
|
+
<div class="method_details ">
|
554
|
+
<h3 class="signature " id="assign_form_attributes-instance_method">
|
555
|
+
|
556
|
+
#<strong>assign_form_attributes</strong>(params) ⇒ <tt>Object</tt>
|
557
|
+
|
558
|
+
|
559
|
+
|
560
|
+
|
561
|
+
|
562
|
+
</h3><div class="docstring">
|
563
|
+
<div class="discussion">
|
564
|
+
|
565
|
+
<p>Assigns the attributes of the form from the params This method is called by the ‘submit` method, but can also be called directly if you need to assign the attributes without submitting the form for example if you want to refresh the form with new data</p>
|
566
|
+
|
567
|
+
|
568
|
+
</div>
|
569
|
+
</div>
|
570
|
+
<div class="tags">
|
571
|
+
<p class="tag_title">Parameters:</p>
|
572
|
+
<ul class="param">
|
573
|
+
|
574
|
+
<li>
|
575
|
+
|
576
|
+
<span class='name'>params</span>
|
577
|
+
|
578
|
+
|
579
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
580
|
+
|
581
|
+
|
582
|
+
|
583
|
+
—
|
584
|
+
<div class='inline'>
|
585
|
+
<p>the params to assign the attributes from</p>
|
586
|
+
</div>
|
587
|
+
|
588
|
+
</li>
|
589
|
+
|
590
|
+
</ul>
|
591
|
+
|
592
|
+
|
593
|
+
</div><table class="source_code">
|
594
|
+
<tr>
|
595
|
+
<td>
|
596
|
+
<pre class="lines">
|
597
|
+
|
598
|
+
|
599
|
+
49
|
600
|
+
50
|
601
|
+
51
|
602
|
+
52
|
603
|
+
53
|
604
|
+
54
|
605
|
+
55
|
606
|
+
56
|
607
|
+
57</pre>
|
608
|
+
</td>
|
609
|
+
<td>
|
610
|
+
<pre class="code"><span class="info file"># File 'lib/hyper_active_form/base.rb', line 49</span>
|
611
|
+
|
612
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_assign_form_attributes'>assign_form_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
|
613
|
+
<span class='id identifier rubyid_run_callbacks'>run_callbacks</span> <span class='symbol'>:assign_form_attributes</span> <span class='kw'>do</span>
|
614
|
+
<span class='id identifier rubyid_params'>params</span> <span class='op'>=</span> <span class='const'>ActionController</span><span class='op'>::</span><span class='const'>Parameters</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span> <span class='kw'>unless</span> <span class='id identifier rubyid_params'>params</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>ActionController</span><span class='op'>::</span><span class='const'>Parameters</span><span class='rparen'>)</span>
|
615
|
+
<span class='id identifier rubyid_attribute_names'>attribute_names</span><span class='period'>.</span><span class='id identifier rubyid_each'>each</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_attribute'>attribute</span><span class='op'>|</span>
|
616
|
+
<span class='id identifier rubyid_default_value'>default_value</span> <span class='op'>=</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid__default_attributes'>_default_attributes</span><span class='lbracket'>[</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rbracket'>]</span><span class='op'>&.</span><span class='id identifier rubyid_value_before_type_cast'>value_before_type_cast</span>
|
617
|
+
<span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='symbol'>:"#{</span><span class='id identifier rubyid_attribute'>attribute</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='comma'>,</span> <span class='id identifier rubyid_params'>params</span><span class='op'>&.</span><span class='id identifier rubyid_dig'>dig</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_default_value'>default_value</span><span class='rparen'>)</span>
|
618
|
+
<span class='kw'>end</span>
|
619
|
+
<span class='kw'>end</span>
|
620
|
+
<span class='kw'>end</span></pre>
|
621
|
+
</td>
|
622
|
+
</tr>
|
623
|
+
</table>
|
624
|
+
</div>
|
625
|
+
|
626
|
+
<div class="method_details ">
|
627
|
+
<h3 class="signature " id="perform-instance_method">
|
628
|
+
|
629
|
+
#<strong>perform</strong> ⇒ <tt>Object</tt>
|
630
|
+
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
</h3><div class="docstring">
|
636
|
+
<div class="discussion">
|
637
|
+
|
638
|
+
|
639
|
+
</div>
|
640
|
+
</div>
|
641
|
+
<div class="tags">
|
642
|
+
|
643
|
+
<p class="tag_title">Raises:</p>
|
644
|
+
<ul class="raise">
|
645
|
+
|
646
|
+
<li>
|
647
|
+
|
648
|
+
|
649
|
+
<span class='type'>(<tt>NotImplementedError</tt>)</span>
|
650
|
+
|
651
|
+
|
652
|
+
|
653
|
+
</li>
|
654
|
+
|
655
|
+
</ul>
|
656
|
+
|
657
|
+
</div><table class="source_code">
|
658
|
+
<tr>
|
659
|
+
<td>
|
660
|
+
<pre class="lines">
|
661
|
+
|
662
|
+
|
663
|
+
39
|
664
|
+
40
|
665
|
+
41</pre>
|
666
|
+
</td>
|
667
|
+
<td>
|
668
|
+
<pre class="code"><span class="info file"># File 'lib/hyper_active_form/base.rb', line 39</span>
|
669
|
+
|
670
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_perform'>perform</span>
|
671
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='const'>NotImplementedError</span>
|
672
|
+
<span class='kw'>end</span></pre>
|
673
|
+
</td>
|
674
|
+
</tr>
|
675
|
+
</table>
|
676
|
+
</div>
|
677
|
+
|
678
|
+
<div class="method_details ">
|
679
|
+
<h3 class="signature " id="setup-instance_method">
|
680
|
+
|
681
|
+
#<strong>setup</strong> ⇒ <tt>Object</tt>
|
682
|
+
|
683
|
+
|
684
|
+
|
685
|
+
|
686
|
+
|
687
|
+
</h3><table class="source_code">
|
688
|
+
<tr>
|
689
|
+
<td>
|
690
|
+
<pre class="lines">
|
691
|
+
|
692
|
+
|
693
|
+
37</pre>
|
694
|
+
</td>
|
695
|
+
<td>
|
696
|
+
<pre class="code"><span class="info file"># File 'lib/hyper_active_form/base.rb', line 37</span>
|
697
|
+
|
698
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_setup'>setup</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
|
699
|
+
</td>
|
700
|
+
</tr>
|
701
|
+
</table>
|
702
|
+
</div>
|
703
|
+
|
704
|
+
<div class="method_details ">
|
705
|
+
<h3 class="signature " id="submit-instance_method">
|
706
|
+
|
707
|
+
#<strong>submit</strong>(params) ⇒ <tt>Boolean</tt>
|
708
|
+
|
709
|
+
|
710
|
+
|
711
|
+
|
712
|
+
|
713
|
+
</h3><div class="docstring">
|
714
|
+
<div class="discussion">
|
715
|
+
|
716
|
+
<p>Submits the form, assigning the attributes from the params, running validations and calling the ‘perform` method if the form is valid</p>
|
717
|
+
|
718
|
+
|
719
|
+
</div>
|
720
|
+
</div>
|
721
|
+
<div class="tags">
|
722
|
+
<p class="tag_title">Parameters:</p>
|
723
|
+
<ul class="param">
|
724
|
+
|
725
|
+
<li>
|
726
|
+
|
727
|
+
<span class='name'>params</span>
|
728
|
+
|
729
|
+
|
730
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
731
|
+
|
732
|
+
|
733
|
+
|
734
|
+
—
|
735
|
+
<div class='inline'>
|
736
|
+
<p>the params to assign the attributes from</p>
|
737
|
+
</div>
|
738
|
+
|
739
|
+
</li>
|
740
|
+
|
741
|
+
</ul>
|
742
|
+
|
743
|
+
<p class="tag_title">Returns:</p>
|
744
|
+
<ul class="return">
|
745
|
+
|
746
|
+
<li>
|
747
|
+
|
748
|
+
|
749
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
750
|
+
|
751
|
+
|
752
|
+
|
753
|
+
—
|
754
|
+
<div class='inline'>
|
755
|
+
<p>true if the form is valid and the ‘perform` method returned something truthy</p>
|
756
|
+
</div>
|
757
|
+
|
758
|
+
</li>
|
759
|
+
|
760
|
+
</ul>
|
761
|
+
|
762
|
+
</div><table class="source_code">
|
763
|
+
<tr>
|
764
|
+
<td>
|
765
|
+
<pre class="lines">
|
766
|
+
|
767
|
+
|
768
|
+
64
|
769
|
+
65
|
770
|
+
66
|
771
|
+
67
|
772
|
+
68
|
773
|
+
69
|
774
|
+
70
|
775
|
+
71</pre>
|
776
|
+
</td>
|
777
|
+
<td>
|
778
|
+
<pre class="code"><span class="info file"># File 'lib/hyper_active_form/base.rb', line 64</span>
|
779
|
+
|
780
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_submit'>submit</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
|
781
|
+
<span class='id identifier rubyid_run_callbacks'>run_callbacks</span> <span class='symbol'>:submit</span> <span class='kw'>do</span>
|
782
|
+
<span class='id identifier rubyid_assign_form_attributes'>assign_form_attributes</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
|
783
|
+
<span class='op'>!</span><span class='op'>!</span><span class='lparen'>(</span><span class='id identifier rubyid_valid?'>valid?</span> <span class='op'>&&</span> <span class='id identifier rubyid_perform'>perform</span><span class='rparen'>)</span>
|
784
|
+
<span class='kw'>end</span>
|
785
|
+
<span class='kw'>rescue</span> <span class='const'><span class='object_link'><a href="../HyperActiveForm.html" title="HyperActiveForm (module)">HyperActiveForm</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="CancelFormSubmit.html" title="HyperActiveForm::CancelFormSubmit (class)">CancelFormSubmit</a></span></span>
|
786
|
+
<span class='kw'>false</span>
|
787
|
+
<span class='kw'>end</span></pre>
|
788
|
+
</td>
|
789
|
+
</tr>
|
790
|
+
</table>
|
791
|
+
</div>
|
792
|
+
|
793
|
+
<div class="method_details ">
|
794
|
+
<h3 class="signature " id="submit!-instance_method">
|
795
|
+
|
796
|
+
#<strong>submit!</strong>(params) ⇒ <tt>Boolean</tt>
|
797
|
+
|
798
|
+
|
799
|
+
|
800
|
+
|
801
|
+
|
802
|
+
</h3><div class="docstring">
|
803
|
+
<div class="discussion">
|
804
|
+
|
805
|
+
<p>Same as ‘submit` but raises a `FormDidNotSubmitError` if the form is not valid</p>
|
806
|
+
|
807
|
+
|
808
|
+
</div>
|
809
|
+
</div>
|
810
|
+
<div class="tags">
|
811
|
+
<p class="tag_title">Parameters:</p>
|
812
|
+
<ul class="param">
|
813
|
+
|
814
|
+
<li>
|
815
|
+
|
816
|
+
<span class='name'>params</span>
|
817
|
+
|
818
|
+
|
819
|
+
<span class='type'>(<tt>Hash</tt>)</span>
|
820
|
+
|
821
|
+
|
822
|
+
|
823
|
+
—
|
824
|
+
<div class='inline'>
|
825
|
+
<p>the params to assign the attributes from</p>
|
826
|
+
</div>
|
827
|
+
|
828
|
+
</li>
|
829
|
+
|
830
|
+
</ul>
|
831
|
+
|
832
|
+
<p class="tag_title">Returns:</p>
|
833
|
+
<ul class="return">
|
834
|
+
|
835
|
+
<li>
|
836
|
+
|
837
|
+
|
838
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
839
|
+
|
840
|
+
|
841
|
+
|
842
|
+
—
|
843
|
+
<div class='inline'>
|
844
|
+
<p>true if the form is valid and the ‘perform` method returned something truthy</p>
|
845
|
+
</div>
|
846
|
+
|
847
|
+
</li>
|
848
|
+
|
849
|
+
</ul>
|
850
|
+
|
851
|
+
</div><table class="source_code">
|
852
|
+
<tr>
|
853
|
+
<td>
|
854
|
+
<pre class="lines">
|
855
|
+
|
856
|
+
|
857
|
+
77
|
858
|
+
78
|
859
|
+
79</pre>
|
860
|
+
</td>
|
861
|
+
<td>
|
862
|
+
<pre class="code"><span class="info file"># File 'lib/hyper_active_form/base.rb', line 77</span>
|
863
|
+
|
864
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_submit!'>submit!</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span>
|
865
|
+
<span class='id identifier rubyid_submit'>submit</span><span class='lparen'>(</span><span class='id identifier rubyid_params'>params</span><span class='rparen'>)</span> <span class='op'>||</span> <span class='id identifier rubyid_raise'>raise</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="../HyperActiveForm.html" title="HyperActiveForm (module)">HyperActiveForm</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="FormDidNotSubmitError.html" title="HyperActiveForm::FormDidNotSubmitError (class)">FormDidNotSubmitError</a></span></span><span class='rparen'>)</span>
|
866
|
+
<span class='kw'>end</span></pre>
|
867
|
+
</td>
|
868
|
+
</tr>
|
869
|
+
</table>
|
870
|
+
</div>
|
871
|
+
|
872
|
+
</div>
|
873
|
+
|
874
|
+
</div>
|
875
|
+
|
876
|
+
<div id="footer">
|
877
|
+
Generated on Sat Dec 14 13:22:03 2024 by
|
878
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
879
|
+
0.9.37 (ruby-3.3.1).
|
880
|
+
</div>
|
881
|
+
|
882
|
+
</div>
|
883
|
+
</body>
|
884
|
+
</html>
|