anchormodel 0.3.1 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.ruby-version +1 -1
- data/CHANGELOG.md +14 -0
- data/EXAMPLES.md +408 -0
- data/Gemfile.lock +1 -1
- data/README.md +43 -1
- data/VERSION +1 -1
- data/anchormodel.gemspec +3 -3
- data/bin/test +9 -0
- data/doc/Anchormodel/ActiveModelTypeValueMulti.html +204 -42
- data/doc/Anchormodel/ActiveModelTypeValueSingle.html +243 -54
- data/doc/Anchormodel/Attribute.html +60 -37
- data/doc/Anchormodel/ModelMixin.html +166 -16
- data/doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html +82 -21
- data/doc/Anchormodel/SimpleFormInputs/Helpers.html +2 -11
- data/doc/Anchormodel/SimpleFormInputs.html +2 -11
- data/doc/Anchormodel/Util.html +497 -38
- data/doc/Anchormodel/Version.html +2 -20
- data/doc/Anchormodel.html +536 -129
- data/doc/AnchormodelCheckBoxesInput.html +22 -1
- data/doc/AnchormodelGenerator.html +64 -13
- data/doc/AnchormodelInput.html +24 -1
- data/doc/AnchormodelRadioButtonsInput.html +22 -1
- data/doc/_index.html +16 -1
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +40 -2
- data/doc/index.html +40 -2
- data/doc/method_list.html +57 -17
- data/doc/top-level-namespace.html +1 -1
- data/lib/anchormodel/active_model_type_value_multi.rb +31 -5
- data/lib/anchormodel/active_model_type_value_single.rb +34 -6
- data/lib/anchormodel/attribute.rb +20 -8
- data/lib/anchormodel/model_mixin.rb +43 -8
- data/lib/anchormodel/simple_form_inputs/anchormodel_check_boxes_input.rb +7 -0
- data/lib/anchormodel/simple_form_inputs/anchormodel_input.rb +9 -0
- data/lib/anchormodel/simple_form_inputs/anchormodel_radio_buttons_input.rb +7 -0
- data/lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb +14 -0
- data/lib/anchormodel/util.rb +102 -17
- data/lib/anchormodel.rb +109 -15
- data/lib/generators/anchormodel/anchormodel_generator.rb +8 -0
- data/test/active_record_model/user_test.rb +221 -10
- data/test/dummy/app/anchormodels/animal.rb +1 -0
- metadata +3 -1
|
@@ -104,6 +104,10 @@
|
|
|
104
104
|
<h2>Overview</h2><div class="docstring">
|
|
105
105
|
<div class="discussion">
|
|
106
106
|
|
|
107
|
+
<p>ActiveModel type adapter for single-value anchormodel attributes.</p>
|
|
108
|
+
|
|
109
|
+
<p>Translates between the in-memory Ruby form (an <code>Anchormodel</code> instance or <code>nil</code>) and the on-disk form (a String key in the DB column). Registered with AR via <code>model_class.attribute(name, ActiveModelTypeValueSingle.new(attribute))</code> by <span class='object_link'><a href="Util.html#install_methods_in_model-class_method" title="Anchormodel::Util.install_methods_in_model (method)">Util.install_methods_in_model</a></span>.</p>
|
|
110
|
+
|
|
107
111
|
|
|
108
112
|
</div>
|
|
109
113
|
</div>
|
|
@@ -113,7 +117,7 @@
|
|
|
113
117
|
<p class="tag_title">See Also:</p>
|
|
114
118
|
<ul class="see">
|
|
115
119
|
|
|
116
|
-
<li><a href="https://www.rubydoc.info/docs/rails/ActiveModel/Type/Value" target="_parent" title="
|
|
120
|
+
<li><a href="https://www.rubydoc.info/docs/rails/ActiveModel/Type/Value" target="_parent" title="Rails type interface">Rails type interface</a></li>
|
|
117
121
|
|
|
118
122
|
</ul>
|
|
119
123
|
|
|
@@ -150,7 +154,9 @@
|
|
|
150
154
|
|
|
151
155
|
|
|
152
156
|
|
|
153
|
-
<span class="summary_desc"><div class='inline'
|
|
157
|
+
<span class="summary_desc"><div class='inline'>
|
|
158
|
+
<p>Returns the value of attribute attribute.</p>
|
|
159
|
+
</div></span>
|
|
154
160
|
|
|
155
161
|
</li>
|
|
156
162
|
|
|
@@ -171,7 +177,7 @@
|
|
|
171
177
|
<li class="public ">
|
|
172
178
|
<span class="summary_signature">
|
|
173
179
|
|
|
174
|
-
<a href="#cast-instance_method" title="#cast (instance method)">#<strong>cast</strong>(value) ⇒
|
|
180
|
+
<a href="#cast-instance_method" title="#cast (instance method)">#<strong>cast</strong>(value) ⇒ Anchormodel<sup>?</sup> </a>
|
|
175
181
|
|
|
176
182
|
|
|
177
183
|
|
|
@@ -186,7 +192,7 @@
|
|
|
186
192
|
|
|
187
193
|
|
|
188
194
|
<span class="summary_desc"><div class='inline'>
|
|
189
|
-
<p>
|
|
195
|
+
<p>Coerces an input value into an Anchormodel instance (or nil).</p>
|
|
190
196
|
</div></span>
|
|
191
197
|
|
|
192
198
|
</li>
|
|
@@ -206,10 +212,12 @@
|
|
|
206
212
|
|
|
207
213
|
|
|
208
214
|
|
|
209
|
-
|
|
215
|
+
<span class="private note title">private</span>
|
|
210
216
|
|
|
211
217
|
|
|
212
|
-
<span class="summary_desc"><div class='inline'
|
|
218
|
+
<span class="summary_desc"><div class='inline'>
|
|
219
|
+
<p>Used by AR’s dirty tracking to detect in-place mutation.</p>
|
|
220
|
+
</div></span>
|
|
213
221
|
|
|
214
222
|
</li>
|
|
215
223
|
|
|
@@ -257,7 +265,9 @@
|
|
|
257
265
|
|
|
258
266
|
|
|
259
267
|
|
|
260
|
-
<span class="summary_desc"><div class='inline'
|
|
268
|
+
<span class="summary_desc"><div class='inline'>
|
|
269
|
+
<p>Reports whether <code>value</code> is a shape that <span class='object_link'><a href="#serialize-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#serialize (method)">#serialize</a></span> would accept.</p>
|
|
270
|
+
</div></span>
|
|
261
271
|
|
|
262
272
|
</li>
|
|
263
273
|
|
|
@@ -265,7 +275,7 @@
|
|
|
265
275
|
<li class="public ">
|
|
266
276
|
<span class="summary_signature">
|
|
267
277
|
|
|
268
|
-
<a href="#serialize-instance_method" title="#serialize (instance method)">#<strong>serialize</strong>(value) ⇒
|
|
278
|
+
<a href="#serialize-instance_method" title="#serialize (instance method)">#<strong>serialize</strong>(value) ⇒ String<sup>?</sup> </a>
|
|
269
279
|
|
|
270
280
|
|
|
271
281
|
|
|
@@ -280,7 +290,7 @@
|
|
|
280
290
|
|
|
281
291
|
|
|
282
292
|
<span class="summary_desc"><div class='inline'>
|
|
283
|
-
<p>
|
|
293
|
+
<p>Converts an Anchormodel-shaped value into the String key stored in the DB.</p>
|
|
284
294
|
</div></span>
|
|
285
295
|
|
|
286
296
|
</li>
|
|
@@ -289,7 +299,7 @@
|
|
|
289
299
|
<li class="public ">
|
|
290
300
|
<span class="summary_signature">
|
|
291
301
|
|
|
292
|
-
<a href="#type-instance_method" title="#type (instance method)">#<strong>type</strong> ⇒
|
|
302
|
+
<a href="#type-instance_method" title="#type (instance method)">#<strong>type</strong> ⇒ Symbol </a>
|
|
293
303
|
|
|
294
304
|
|
|
295
305
|
|
|
@@ -303,7 +313,9 @@
|
|
|
303
313
|
|
|
304
314
|
|
|
305
315
|
|
|
306
|
-
<span class="summary_desc"><div class='inline'
|
|
316
|
+
<span class="summary_desc"><div class='inline'>
|
|
317
|
+
<p><code>:anchormodel</code> — the type identifier.</p>
|
|
318
|
+
</div></span>
|
|
307
319
|
|
|
308
320
|
</li>
|
|
309
321
|
|
|
@@ -333,7 +345,22 @@
|
|
|
333
345
|
</div>
|
|
334
346
|
</div>
|
|
335
347
|
<div class="tags">
|
|
348
|
+
<p class="tag_title">Parameters:</p>
|
|
349
|
+
<ul class="param">
|
|
350
|
+
|
|
351
|
+
<li>
|
|
352
|
+
|
|
353
|
+
<span class='name'>attribute</span>
|
|
354
|
+
|
|
355
|
+
|
|
356
|
+
<span class='type'>(<tt><span class='object_link'><a href="Attribute.html" title="Anchormodel::Attribute (class)">Anchormodel::Attribute</a></span></tt>)</span>
|
|
357
|
+
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
</li>
|
|
336
361
|
|
|
362
|
+
</ul>
|
|
363
|
+
|
|
337
364
|
|
|
338
365
|
</div><table class="source_code">
|
|
339
366
|
<tr>
|
|
@@ -341,13 +368,13 @@
|
|
|
341
368
|
<pre class="lines">
|
|
342
369
|
|
|
343
370
|
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
371
|
+
15
|
|
372
|
+
16
|
|
373
|
+
17
|
|
374
|
+
18</pre>
|
|
348
375
|
</td>
|
|
349
376
|
<td>
|
|
350
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
377
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 15</span>
|
|
351
378
|
|
|
352
379
|
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span>
|
|
353
380
|
<span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
|
@@ -377,6 +404,8 @@
|
|
|
377
404
|
</h3><div class="docstring">
|
|
378
405
|
<div class="discussion">
|
|
379
406
|
|
|
407
|
+
<p>Returns the value of attribute attribute.</p>
|
|
408
|
+
|
|
380
409
|
|
|
381
410
|
</div>
|
|
382
411
|
</div>
|
|
@@ -389,12 +418,12 @@
|
|
|
389
418
|
<pre class="lines">
|
|
390
419
|
|
|
391
420
|
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
421
|
+
12
|
|
422
|
+
13
|
|
423
|
+
14</pre>
|
|
395
424
|
</td>
|
|
396
425
|
<td>
|
|
397
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
426
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 12</span>
|
|
398
427
|
|
|
399
428
|
<span class='kw'>def</span> <span class='id identifier rubyid_attribute'>attribute</span>
|
|
400
429
|
<span class='ivar'>@attribute</span>
|
|
@@ -414,7 +443,7 @@
|
|
|
414
443
|
<div class="method_details first">
|
|
415
444
|
<h3 class="signature first" id="cast-instance_method">
|
|
416
445
|
|
|
417
|
-
#<strong>cast</strong>(value) ⇒ <tt>
|
|
446
|
+
#<strong>cast</strong>(value) ⇒ <tt><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></tt><sup>?</sup>
|
|
418
447
|
|
|
419
448
|
|
|
420
449
|
|
|
@@ -423,13 +452,69 @@
|
|
|
423
452
|
</h3><div class="docstring">
|
|
424
453
|
<div class="discussion">
|
|
425
454
|
|
|
426
|
-
<p>
|
|
455
|
+
<p>Coerces an input value into an Anchormodel instance (or nil). Used by Rails when reading from the DB, when assigning via mass-assignment, and for dirty-tracking.</p>
|
|
427
456
|
|
|
428
457
|
|
|
429
458
|
</div>
|
|
430
459
|
</div>
|
|
431
460
|
<div class="tags">
|
|
461
|
+
<p class="tag_title">Parameters:</p>
|
|
462
|
+
<ul class="param">
|
|
463
|
+
|
|
464
|
+
<li>
|
|
465
|
+
|
|
466
|
+
<span class='name'>value</span>
|
|
467
|
+
|
|
468
|
+
|
|
469
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></tt>, <tt>nil</tt>)</span>
|
|
470
|
+
|
|
471
|
+
|
|
472
|
+
|
|
473
|
+
—
|
|
474
|
+
<div class='inline'>
|
|
475
|
+
<p>DB value, user input, or already-cast instance.</p>
|
|
476
|
+
</div>
|
|
477
|
+
|
|
478
|
+
</li>
|
|
432
479
|
|
|
480
|
+
</ul>
|
|
481
|
+
|
|
482
|
+
<p class="tag_title">Returns:</p>
|
|
483
|
+
<ul class="return">
|
|
484
|
+
|
|
485
|
+
<li>
|
|
486
|
+
|
|
487
|
+
|
|
488
|
+
<span class='type'>(<tt><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></tt>, <tt>nil</tt>)</span>
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
|
|
492
|
+
—
|
|
493
|
+
<div class='inline'>
|
|
494
|
+
<p>The matching Anchormodel instance, or <code>nil</code> for blank input.</p>
|
|
495
|
+
</div>
|
|
496
|
+
|
|
497
|
+
</li>
|
|
498
|
+
|
|
499
|
+
</ul>
|
|
500
|
+
<p class="tag_title">Raises:</p>
|
|
501
|
+
<ul class="raise">
|
|
502
|
+
|
|
503
|
+
<li>
|
|
504
|
+
|
|
505
|
+
|
|
506
|
+
<span class='type'>(<tt><span class='object_link'><a href="InvalidKey.html" title="Anchormodel::InvalidKey (class)">Anchormodel::InvalidKey</a></span></tt>)</span>
|
|
507
|
+
|
|
508
|
+
|
|
509
|
+
|
|
510
|
+
—
|
|
511
|
+
<div class='inline'>
|
|
512
|
+
<p>if a String/Symbol is not a registered key.</p>
|
|
513
|
+
</div>
|
|
514
|
+
|
|
515
|
+
</li>
|
|
516
|
+
|
|
517
|
+
</ul>
|
|
433
518
|
|
|
434
519
|
</div><table class="source_code">
|
|
435
520
|
<tr>
|
|
@@ -437,14 +522,14 @@
|
|
|
437
522
|
<pre class="lines">
|
|
438
523
|
|
|
439
524
|
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
525
|
+
31
|
|
526
|
+
32
|
|
527
|
+
33
|
|
528
|
+
34
|
|
529
|
+
35</pre>
|
|
445
530
|
</td>
|
|
446
531
|
<td>
|
|
447
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
532
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 31</span>
|
|
448
533
|
|
|
449
534
|
<span class='kw'>def</span> <span class='id identifier rubyid_cast'>cast</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
450
535
|
<span class='id identifier rubyid_value'>value</span> <span class='op'>=</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_presence'>presence</span>
|
|
@@ -467,7 +552,13 @@
|
|
|
467
552
|
|
|
468
553
|
</h3><div class="docstring">
|
|
469
554
|
<div class="discussion">
|
|
470
|
-
|
|
555
|
+
<p class="note private">
|
|
556
|
+
<strong>This method is part of a private API.</strong>
|
|
557
|
+
You should avoid using this method if possible, as it may be removed or be changed in the future.
|
|
558
|
+
</p>
|
|
559
|
+
|
|
560
|
+
<p>Used by AR’s dirty tracking to detect in-place mutation.</p>
|
|
561
|
+
|
|
471
562
|
|
|
472
563
|
</div>
|
|
473
564
|
</div>
|
|
@@ -493,13 +584,13 @@
|
|
|
493
584
|
<pre class="lines">
|
|
494
585
|
|
|
495
586
|
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
587
|
+
60
|
|
588
|
+
61
|
|
589
|
+
62
|
|
590
|
+
63</pre>
|
|
500
591
|
</td>
|
|
501
592
|
<td>
|
|
502
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
593
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 60</span>
|
|
503
594
|
|
|
504
595
|
<span class='kw'>def</span> <span class='id identifier rubyid_changed_in_place?'>changed_in_place?</span><span class='lparen'>(</span><span class='id identifier rubyid_raw_old_value'>raw_old_value</span><span class='comma'>,</span> <span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
505
596
|
<span class='id identifier rubyid_old_value'>old_value</span> <span class='op'>=</span> <span class='id identifier rubyid_deserialize'>deserialize</span><span class='lparen'>(</span><span class='id identifier rubyid_raw_old_value'>raw_old_value</span><span class='rparen'>)</span>
|
|
@@ -522,11 +613,28 @@
|
|
|
522
613
|
</h3><div class="docstring">
|
|
523
614
|
<div class="discussion">
|
|
524
615
|
|
|
616
|
+
<p>Reports whether <code>value</code> is a shape that <span class='object_link'><a href="#serialize-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#serialize (method)">#serialize</a></span> would accept. Used by AR’s <code>Arel::Nodes::HomogeneousIn</code> to gate which array elements get bound into IN clauses. Returns true for any String/Symbol/<code>nil</code>/Anchormodel instance — actual key validation is deferred to <span class='object_link'><a href="#serialize-instance_method" title="Anchormodel::ActiveModelTypeValueSingle#serialize (method)">#serialize</a></span>.</p>
|
|
617
|
+
|
|
525
618
|
|
|
526
619
|
</div>
|
|
527
620
|
</div>
|
|
528
621
|
<div class="tags">
|
|
622
|
+
<p class="tag_title">Parameters:</p>
|
|
623
|
+
<ul class="param">
|
|
624
|
+
|
|
625
|
+
<li>
|
|
626
|
+
|
|
627
|
+
<span class='name'>value</span>
|
|
628
|
+
|
|
629
|
+
|
|
630
|
+
<span class='type'>(<tt>Object</tt>)</span>
|
|
631
|
+
|
|
632
|
+
|
|
633
|
+
|
|
634
|
+
</li>
|
|
529
635
|
|
|
636
|
+
</ul>
|
|
637
|
+
|
|
530
638
|
<p class="tag_title">Returns:</p>
|
|
531
639
|
<ul class="return">
|
|
532
640
|
|
|
@@ -547,16 +655,14 @@
|
|
|
547
655
|
<pre class="lines">
|
|
548
656
|
|
|
549
657
|
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
30</pre>
|
|
658
|
+
54
|
|
659
|
+
55
|
|
660
|
+
56</pre>
|
|
554
661
|
</td>
|
|
555
662
|
<td>
|
|
556
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
663
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 54</span>
|
|
557
664
|
|
|
558
665
|
<span class='kw'>def</span> <span class='id identifier rubyid_serializable?'>serializable?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
559
|
-
<span class='kw'>return</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_all?'>all?</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_scalar_serializable?'>scalar_serializable?</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Array</span><span class='rparen'>)</span>
|
|
560
666
|
<span class='id identifier rubyid_scalar_serializable?'>scalar_serializable?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
561
667
|
<span class='kw'>end</span></pre>
|
|
562
668
|
</td>
|
|
@@ -567,7 +673,7 @@
|
|
|
567
673
|
<div class="method_details ">
|
|
568
674
|
<h3 class="signature " id="serialize-instance_method">
|
|
569
675
|
|
|
570
|
-
#<strong>serialize</strong>(value) ⇒ <tt>
|
|
676
|
+
#<strong>serialize</strong>(value) ⇒ <tt>String</tt><sup>?</sup>
|
|
571
677
|
|
|
572
678
|
|
|
573
679
|
|
|
@@ -576,13 +682,78 @@
|
|
|
576
682
|
</h3><div class="docstring">
|
|
577
683
|
<div class="discussion">
|
|
578
684
|
|
|
579
|
-
<p>
|
|
685
|
+
<p>Converts an Anchormodel-shaped value into the String key stored in the DB.</p>
|
|
580
686
|
|
|
581
687
|
|
|
582
688
|
</div>
|
|
583
689
|
</div>
|
|
584
690
|
<div class="tags">
|
|
691
|
+
<p class="tag_title">Parameters:</p>
|
|
692
|
+
<ul class="param">
|
|
693
|
+
|
|
694
|
+
<li>
|
|
695
|
+
|
|
696
|
+
<span class='name'>value</span>
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>, <tt><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></tt>, <tt>nil</tt>)</span>
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
|
|
703
|
+
</li>
|
|
704
|
+
|
|
705
|
+
</ul>
|
|
706
|
+
|
|
707
|
+
<p class="tag_title">Returns:</p>
|
|
708
|
+
<ul class="return">
|
|
709
|
+
|
|
710
|
+
<li>
|
|
711
|
+
|
|
712
|
+
|
|
713
|
+
<span class='type'>(<tt>String</tt>, <tt>nil</tt>)</span>
|
|
714
|
+
|
|
715
|
+
|
|
716
|
+
|
|
717
|
+
—
|
|
718
|
+
<div class='inline'>
|
|
719
|
+
<p>The key as a String, or <code>nil</code> for blank input.</p>
|
|
720
|
+
</div>
|
|
721
|
+
|
|
722
|
+
</li>
|
|
723
|
+
|
|
724
|
+
</ul>
|
|
725
|
+
<p class="tag_title">Raises:</p>
|
|
726
|
+
<ul class="raise">
|
|
727
|
+
|
|
728
|
+
<li>
|
|
729
|
+
|
|
730
|
+
|
|
731
|
+
<span class='type'>(<tt><span class='object_link'><a href="InvalidKey.html" title="Anchormodel::InvalidKey (class)">Anchormodel::InvalidKey</a></span></tt>)</span>
|
|
732
|
+
|
|
733
|
+
|
|
734
|
+
|
|
735
|
+
—
|
|
736
|
+
<div class='inline'>
|
|
737
|
+
<p>for unknown String/Symbol keys.</p>
|
|
738
|
+
</div>
|
|
739
|
+
|
|
740
|
+
</li>
|
|
585
741
|
|
|
742
|
+
<li>
|
|
743
|
+
|
|
744
|
+
|
|
745
|
+
<span class='type'>(<tt>RuntimeError</tt>)</span>
|
|
746
|
+
|
|
747
|
+
|
|
748
|
+
|
|
749
|
+
—
|
|
750
|
+
<div class='inline'>
|
|
751
|
+
<p>for any other input type (e.g. Array, Integer).</p>
|
|
752
|
+
</div>
|
|
753
|
+
|
|
754
|
+
</li>
|
|
755
|
+
|
|
756
|
+
</ul>
|
|
586
757
|
|
|
587
758
|
</div><table class="source_code">
|
|
588
759
|
<tr>
|
|
@@ -590,16 +761,14 @@
|
|
|
590
761
|
<pre class="lines">
|
|
591
762
|
|
|
592
763
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
25</pre>
|
|
764
|
+
43
|
|
765
|
+
44
|
|
766
|
+
45</pre>
|
|
597
767
|
</td>
|
|
598
768
|
<td>
|
|
599
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
769
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 43</span>
|
|
600
770
|
|
|
601
771
|
<span class='kw'>def</span> <span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
602
|
-
<span class='kw'>return</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_v'>v</span><span class='op'>|</span> <span class='id identifier rubyid_serialize_scalar'>serialize_scalar</span><span class='lparen'>(</span><span class='id identifier rubyid_v'>v</span><span class='rparen'>)</span> <span class='rbrace'>}</span> <span class='kw'>if</span> <span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_is_a?'>is_a?</span><span class='lparen'>(</span><span class='const'>Array</span><span class='rparen'>)</span>
|
|
603
772
|
<span class='id identifier rubyid_serialize_scalar'>serialize_scalar</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
|
604
773
|
<span class='kw'>end</span></pre>
|
|
605
774
|
</td>
|
|
@@ -610,7 +779,7 @@
|
|
|
610
779
|
<div class="method_details ">
|
|
611
780
|
<h3 class="signature " id="type-instance_method">
|
|
612
781
|
|
|
613
|
-
#<strong>type</strong> ⇒ <tt>
|
|
782
|
+
#<strong>type</strong> ⇒ <tt>Symbol</tt>
|
|
614
783
|
|
|
615
784
|
|
|
616
785
|
|
|
@@ -619,11 +788,31 @@
|
|
|
619
788
|
</h3><div class="docstring">
|
|
620
789
|
<div class="discussion">
|
|
621
790
|
|
|
791
|
+
<p>Returns <code>:anchormodel</code> — the type identifier.</p>
|
|
792
|
+
|
|
622
793
|
|
|
623
794
|
</div>
|
|
624
795
|
</div>
|
|
625
796
|
<div class="tags">
|
|
626
797
|
|
|
798
|
+
<p class="tag_title">Returns:</p>
|
|
799
|
+
<ul class="return">
|
|
800
|
+
|
|
801
|
+
<li>
|
|
802
|
+
|
|
803
|
+
|
|
804
|
+
<span class='type'>(<tt>Symbol</tt>)</span>
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
|
|
808
|
+
—
|
|
809
|
+
<div class='inline'>
|
|
810
|
+
<p><code>:anchormodel</code> — the type identifier.</p>
|
|
811
|
+
</div>
|
|
812
|
+
|
|
813
|
+
</li>
|
|
814
|
+
|
|
815
|
+
</ul>
|
|
627
816
|
|
|
628
817
|
</div><table class="source_code">
|
|
629
818
|
<tr>
|
|
@@ -631,12 +820,12 @@
|
|
|
631
820
|
<pre class="lines">
|
|
632
821
|
|
|
633
822
|
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
823
|
+
21
|
|
824
|
+
22
|
|
825
|
+
23</pre>
|
|
637
826
|
</td>
|
|
638
827
|
<td>
|
|
639
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line
|
|
828
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 21</span>
|
|
640
829
|
|
|
641
830
|
<span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span>
|
|
642
831
|
<span class='symbol'>:anchormodel</span>
|
|
@@ -651,7 +840,7 @@
|
|
|
651
840
|
</div>
|
|
652
841
|
|
|
653
842
|
<div id="footer">
|
|
654
|
-
Generated on Wed May 13
|
|
843
|
+
Generated on Wed May 13 15:48:25 2026 by
|
|
655
844
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
656
845
|
0.9.28 (ruby-3.3.5).
|
|
657
846
|
</div>
|