anchormodel 0.1.4 → 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/.gitignore +2 -1
- data/CHANGELOG.md +10 -0
- data/Gemfile.lock +1 -1
- data/README.md +114 -3
- data/VERSION +1 -1
- data/anchormodel.gemspec +5 -5
- data/doc/Anchormodel/ActiveModelTypeValueSingle.html +697 -0
- data/doc/Anchormodel/Attribute.html +109 -9
- data/doc/Anchormodel/ModelMixin.html +75 -3
- data/doc/Anchormodel/SimpleFormInputs/Helpers/AnchormodelInputsCommon.html +269 -0
- data/doc/Anchormodel/SimpleFormInputs/Helpers.html +124 -0
- data/doc/Anchormodel/SimpleFormInputs.html +124 -0
- data/doc/Anchormodel/Util.html +612 -0
- data/doc/Anchormodel/Version.html +3 -3
- data/doc/Anchormodel.html +99 -34
- data/doc/AnchormodelGenerator.html +201 -0
- data/doc/AnchormodelInput.html +140 -0
- data/doc/AnchormodelRadioButtonsInput.html +140 -0
- data/doc/_index.html +63 -4
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +109 -6
- data/doc/frames.html +5 -10
- data/doc/index.html +109 -6
- data/doc/method_list.html +70 -6
- data/doc/top-level-namespace.html +4 -4
- data/lib/anchormodel/active_model_type_value_multi.rb +31 -0
- data/lib/anchormodel/active_model_type_value_single.rb +4 -2
- data/lib/anchormodel/attribute.rb +7 -1
- data/lib/anchormodel/model_mixin.rb +7 -0
- data/lib/anchormodel/simple_form_inputs/anchormodel_check_boxes_input.rb +23 -0
- data/lib/anchormodel/simple_form_inputs/anchormodel_input.rb +21 -0
- data/lib/anchormodel/simple_form_inputs/anchormodel_radio_buttons_input.rb +23 -0
- data/lib/anchormodel/simple_form_inputs/helpers/anchormodel_inputs_common.rb +54 -0
- data/lib/anchormodel/util.rb +57 -7
- data/lib/anchormodel.rb +10 -0
- data/test/active_record_model/user_test.rb +73 -9
- data/test/dummy/app/anchormodels/animal.rb +6 -0
- data/test/dummy/app/models/user.rb +1 -0
- data/test/dummy/db/migrate/20240425182000_add_animals_to_users.rb +5 -0
- data/test/dummy/db/schema.rb +2 -1
- metadata +18 -4
- data/pkg/anchormodel-0.1.3.gem +0 -0
@@ -0,0 +1,697 @@
|
|
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: Anchormodel::ActiveModelTypeValueSingle
|
8
|
+
|
9
|
+
— Documentation by YARD 0.9.34
|
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 = "Anchormodel::ActiveModelTypeValueSingle";
|
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 (A)</a> »
|
40
|
+
<span class='title'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span>
|
41
|
+
»
|
42
|
+
<span class="title">ActiveModelTypeValueSingle</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: Anchormodel::ActiveModelTypeValueSingle
|
63
|
+
|
64
|
+
|
65
|
+
|
66
|
+
</h1>
|
67
|
+
<div class="box_info">
|
68
|
+
|
69
|
+
<dl>
|
70
|
+
<dt>Inherits:</dt>
|
71
|
+
<dd>
|
72
|
+
<span class="inheritName">ActiveModel::Type::Value</span>
|
73
|
+
|
74
|
+
<ul class="fullTree">
|
75
|
+
<li>Object</li>
|
76
|
+
|
77
|
+
<li class="next">ActiveModel::Type::Value</li>
|
78
|
+
|
79
|
+
<li class="next">Anchormodel::ActiveModelTypeValueSingle</li>
|
80
|
+
|
81
|
+
</ul>
|
82
|
+
<a href="#" class="inheritanceTree">show all</a>
|
83
|
+
|
84
|
+
</dd>
|
85
|
+
</dl>
|
86
|
+
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
|
91
|
+
|
92
|
+
|
93
|
+
|
94
|
+
|
95
|
+
|
96
|
+
|
97
|
+
<dl>
|
98
|
+
<dt>Defined in:</dt>
|
99
|
+
<dd>lib/anchormodel/active_model_type_value_single.rb</dd>
|
100
|
+
</dl>
|
101
|
+
|
102
|
+
</div>
|
103
|
+
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
105
|
+
<div class="discussion">
|
106
|
+
|
107
|
+
|
108
|
+
</div>
|
109
|
+
</div>
|
110
|
+
<div class="tags">
|
111
|
+
|
112
|
+
|
113
|
+
<p class="tag_title">See Also:</p>
|
114
|
+
<ul class="see">
|
115
|
+
|
116
|
+
<li><a href="https://www.rubydoc.info/docs/rails/ActiveModel/Type/Value" target="_parent" title="https://www.rubydoc.info/docs/rails/ActiveModel/Type/Value">https://www.rubydoc.info/docs/rails/ActiveModel/Type/Value</a></li>
|
117
|
+
|
118
|
+
</ul>
|
119
|
+
|
120
|
+
</div><div id="subclasses">
|
121
|
+
<h2>Direct Known Subclasses</h2>
|
122
|
+
<p class="children"><span class='object_link'><a href="ActiveModelTypeValueMulti.html" title="Anchormodel::ActiveModelTypeValueMulti (class)">ActiveModelTypeValueMulti</a></span></p>
|
123
|
+
</div>
|
124
|
+
|
125
|
+
|
126
|
+
|
127
|
+
|
128
|
+
<h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
|
129
|
+
<ul class="summary">
|
130
|
+
|
131
|
+
<li class="public ">
|
132
|
+
<span class="summary_signature">
|
133
|
+
|
134
|
+
<a href="#attribute-instance_method" title="#attribute (instance method)">#<strong>attribute</strong> ⇒ Object </a>
|
135
|
+
|
136
|
+
|
137
|
+
|
138
|
+
</span>
|
139
|
+
|
140
|
+
|
141
|
+
|
142
|
+
|
143
|
+
<span class="note title readonly">readonly</span>
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
|
148
|
+
|
149
|
+
|
150
|
+
|
151
|
+
|
152
|
+
|
153
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
154
|
+
|
155
|
+
</li>
|
156
|
+
|
157
|
+
|
158
|
+
</ul>
|
159
|
+
|
160
|
+
|
161
|
+
|
162
|
+
|
163
|
+
|
164
|
+
<h2>
|
165
|
+
Instance Method Summary
|
166
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
167
|
+
</h2>
|
168
|
+
|
169
|
+
<ul class="summary">
|
170
|
+
|
171
|
+
<li class="public ">
|
172
|
+
<span class="summary_signature">
|
173
|
+
|
174
|
+
<a href="#cast-instance_method" title="#cast (instance method)">#<strong>cast</strong>(value) ⇒ Object </a>
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
</span>
|
179
|
+
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
|
184
|
+
|
185
|
+
|
186
|
+
|
187
|
+
|
188
|
+
<span class="summary_desc"><div class='inline'>
|
189
|
+
<p>This converts DB or input to an Anchormodel instance.</p>
|
190
|
+
</div></span>
|
191
|
+
|
192
|
+
</li>
|
193
|
+
|
194
|
+
|
195
|
+
<li class="public ">
|
196
|
+
<span class="summary_signature">
|
197
|
+
|
198
|
+
<a href="#changed_in_place%3F-instance_method" title="#changed_in_place? (instance method)">#<strong>changed_in_place?</strong>(raw_old_value, value) ⇒ Boolean </a>
|
199
|
+
|
200
|
+
|
201
|
+
|
202
|
+
</span>
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
|
208
|
+
|
209
|
+
|
210
|
+
|
211
|
+
|
212
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
213
|
+
|
214
|
+
</li>
|
215
|
+
|
216
|
+
|
217
|
+
<li class="public ">
|
218
|
+
<span class="summary_signature">
|
219
|
+
|
220
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(attribute) ⇒ ActiveModelTypeValueSingle </a>
|
221
|
+
|
222
|
+
|
223
|
+
|
224
|
+
</span>
|
225
|
+
|
226
|
+
|
227
|
+
<span class="note title constructor">constructor</span>
|
228
|
+
|
229
|
+
|
230
|
+
|
231
|
+
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
<span class="summary_desc"><div class='inline'>
|
237
|
+
<p>A new instance of ActiveModelTypeValueSingle.</p>
|
238
|
+
</div></span>
|
239
|
+
|
240
|
+
</li>
|
241
|
+
|
242
|
+
|
243
|
+
<li class="public ">
|
244
|
+
<span class="summary_signature">
|
245
|
+
|
246
|
+
<a href="#serializable%3F-instance_method" title="#serializable? (instance method)">#<strong>serializable?</strong>(value) ⇒ Boolean </a>
|
247
|
+
|
248
|
+
|
249
|
+
|
250
|
+
</span>
|
251
|
+
|
252
|
+
|
253
|
+
|
254
|
+
|
255
|
+
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
|
260
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
261
|
+
|
262
|
+
</li>
|
263
|
+
|
264
|
+
|
265
|
+
<li class="public ">
|
266
|
+
<span class="summary_signature">
|
267
|
+
|
268
|
+
<a href="#serialize-instance_method" title="#serialize (instance method)">#<strong>serialize</strong>(value) ⇒ Object </a>
|
269
|
+
|
270
|
+
|
271
|
+
|
272
|
+
</span>
|
273
|
+
|
274
|
+
|
275
|
+
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
|
280
|
+
|
281
|
+
|
282
|
+
<span class="summary_desc"><div class='inline'>
|
283
|
+
<p>This converts an Anchormodel instance to string for DB.</p>
|
284
|
+
</div></span>
|
285
|
+
|
286
|
+
</li>
|
287
|
+
|
288
|
+
|
289
|
+
<li class="public ">
|
290
|
+
<span class="summary_signature">
|
291
|
+
|
292
|
+
<a href="#type-instance_method" title="#type (instance method)">#<strong>type</strong> ⇒ Object </a>
|
293
|
+
|
294
|
+
|
295
|
+
|
296
|
+
</span>
|
297
|
+
|
298
|
+
|
299
|
+
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
|
306
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
307
|
+
|
308
|
+
</li>
|
309
|
+
|
310
|
+
|
311
|
+
</ul>
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<div id="constructor_details" class="method_details_list">
|
316
|
+
<h2>Constructor Details</h2>
|
317
|
+
|
318
|
+
<div class="method_details first">
|
319
|
+
<h3 class="signature first" id="initialize-instance_method">
|
320
|
+
|
321
|
+
#<strong>initialize</strong>(attribute) ⇒ <tt><span class='object_link'><a href="" title="Anchormodel::ActiveModelTypeValueSingle (class)">ActiveModelTypeValueSingle</a></span></tt>
|
322
|
+
|
323
|
+
|
324
|
+
|
325
|
+
|
326
|
+
|
327
|
+
</h3><div class="docstring">
|
328
|
+
<div class="discussion">
|
329
|
+
|
330
|
+
<p>Returns a new instance of ActiveModelTypeValueSingle.</p>
|
331
|
+
|
332
|
+
|
333
|
+
</div>
|
334
|
+
</div>
|
335
|
+
<div class="tags">
|
336
|
+
|
337
|
+
|
338
|
+
</div><table class="source_code">
|
339
|
+
<tr>
|
340
|
+
<td>
|
341
|
+
<pre class="lines">
|
342
|
+
|
343
|
+
|
344
|
+
5
|
345
|
+
6
|
346
|
+
7
|
347
|
+
8</pre>
|
348
|
+
</td>
|
349
|
+
<td>
|
350
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 5</span>
|
351
|
+
|
352
|
+
<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
|
+
<span class='kw'>super</span><span class='lparen'>(</span><span class='rparen'>)</span>
|
354
|
+
<span class='ivar'>@attribute</span> <span class='op'>=</span> <span class='id identifier rubyid_attribute'>attribute</span>
|
355
|
+
<span class='kw'>end</span></pre>
|
356
|
+
</td>
|
357
|
+
</tr>
|
358
|
+
</table>
|
359
|
+
</div>
|
360
|
+
|
361
|
+
</div>
|
362
|
+
|
363
|
+
<div id="instance_attr_details" class="attr_details">
|
364
|
+
<h2>Instance Attribute Details</h2>
|
365
|
+
|
366
|
+
|
367
|
+
<span id=""></span>
|
368
|
+
<div class="method_details first">
|
369
|
+
<h3 class="signature first" id="attribute-instance_method">
|
370
|
+
|
371
|
+
#<strong>attribute</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
372
|
+
|
373
|
+
|
374
|
+
|
375
|
+
|
376
|
+
|
377
|
+
</h3><div class="docstring">
|
378
|
+
<div class="discussion">
|
379
|
+
|
380
|
+
|
381
|
+
</div>
|
382
|
+
</div>
|
383
|
+
<div class="tags">
|
384
|
+
|
385
|
+
|
386
|
+
</div><table class="source_code">
|
387
|
+
<tr>
|
388
|
+
<td>
|
389
|
+
<pre class="lines">
|
390
|
+
|
391
|
+
|
392
|
+
3
|
393
|
+
4
|
394
|
+
5</pre>
|
395
|
+
</td>
|
396
|
+
<td>
|
397
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 3</span>
|
398
|
+
|
399
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_attribute'>attribute</span>
|
400
|
+
<span class='ivar'>@attribute</span>
|
401
|
+
<span class='kw'>end</span></pre>
|
402
|
+
</td>
|
403
|
+
</tr>
|
404
|
+
</table>
|
405
|
+
</div>
|
406
|
+
|
407
|
+
</div>
|
408
|
+
|
409
|
+
|
410
|
+
<div id="instance_method_details" class="method_details_list">
|
411
|
+
<h2>Instance Method Details</h2>
|
412
|
+
|
413
|
+
|
414
|
+
<div class="method_details first">
|
415
|
+
<h3 class="signature first" id="cast-instance_method">
|
416
|
+
|
417
|
+
#<strong>cast</strong>(value) ⇒ <tt>Object</tt>
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
|
422
|
+
|
423
|
+
</h3><div class="docstring">
|
424
|
+
<div class="discussion">
|
425
|
+
|
426
|
+
<p>This converts DB or input to an Anchormodel instance</p>
|
427
|
+
|
428
|
+
|
429
|
+
</div>
|
430
|
+
</div>
|
431
|
+
<div class="tags">
|
432
|
+
|
433
|
+
|
434
|
+
</div><table class="source_code">
|
435
|
+
<tr>
|
436
|
+
<td>
|
437
|
+
<pre class="lines">
|
438
|
+
|
439
|
+
|
440
|
+
15
|
441
|
+
16
|
442
|
+
17
|
443
|
+
18
|
444
|
+
19</pre>
|
445
|
+
</td>
|
446
|
+
<td>
|
447
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 15</span>
|
448
|
+
|
449
|
+
<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
|
+
<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>
|
451
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_value'>value</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='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='rparen'>)</span>
|
452
|
+
<span class='kw'>return</span> <span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_find'>find</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='rparen'>)</span>
|
453
|
+
<span class='kw'>end</span></pre>
|
454
|
+
</td>
|
455
|
+
</tr>
|
456
|
+
</table>
|
457
|
+
</div>
|
458
|
+
|
459
|
+
<div class="method_details ">
|
460
|
+
<h3 class="signature " id="changed_in_place?-instance_method">
|
461
|
+
|
462
|
+
#<strong>changed_in_place?</strong>(raw_old_value, value) ⇒ <tt>Boolean</tt>
|
463
|
+
|
464
|
+
|
465
|
+
|
466
|
+
|
467
|
+
|
468
|
+
</h3><div class="docstring">
|
469
|
+
<div class="discussion">
|
470
|
+
|
471
|
+
|
472
|
+
</div>
|
473
|
+
</div>
|
474
|
+
<div class="tags">
|
475
|
+
|
476
|
+
<p class="tag_title">Returns:</p>
|
477
|
+
<ul class="return">
|
478
|
+
|
479
|
+
<li>
|
480
|
+
|
481
|
+
|
482
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
483
|
+
|
484
|
+
|
485
|
+
|
486
|
+
</li>
|
487
|
+
|
488
|
+
</ul>
|
489
|
+
|
490
|
+
</div><table class="source_code">
|
491
|
+
<tr>
|
492
|
+
<td>
|
493
|
+
<pre class="lines">
|
494
|
+
|
495
|
+
|
496
|
+
50
|
497
|
+
51
|
498
|
+
52
|
499
|
+
53</pre>
|
500
|
+
</td>
|
501
|
+
<td>
|
502
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 50</span>
|
503
|
+
|
504
|
+
<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
|
+
<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>
|
506
|
+
<span class='id identifier rubyid_old_value'>old_value</span> <span class='op'>!=</span> <span class='id identifier rubyid_value'>value</span>
|
507
|
+
<span class='kw'>end</span></pre>
|
508
|
+
</td>
|
509
|
+
</tr>
|
510
|
+
</table>
|
511
|
+
</div>
|
512
|
+
|
513
|
+
<div class="method_details ">
|
514
|
+
<h3 class="signature " id="serializable?-instance_method">
|
515
|
+
|
516
|
+
#<strong>serializable?</strong>(value) ⇒ <tt>Boolean</tt>
|
517
|
+
|
518
|
+
|
519
|
+
|
520
|
+
|
521
|
+
|
522
|
+
</h3><div class="docstring">
|
523
|
+
<div class="discussion">
|
524
|
+
|
525
|
+
|
526
|
+
</div>
|
527
|
+
</div>
|
528
|
+
<div class="tags">
|
529
|
+
|
530
|
+
<p class="tag_title">Returns:</p>
|
531
|
+
<ul class="return">
|
532
|
+
|
533
|
+
<li>
|
534
|
+
|
535
|
+
|
536
|
+
<span class='type'>(<tt>Boolean</tt>)</span>
|
537
|
+
|
538
|
+
|
539
|
+
|
540
|
+
</li>
|
541
|
+
|
542
|
+
</ul>
|
543
|
+
|
544
|
+
</div><table class="source_code">
|
545
|
+
<tr>
|
546
|
+
<td>
|
547
|
+
<pre class="lines">
|
548
|
+
|
549
|
+
|
550
|
+
39
|
551
|
+
40
|
552
|
+
41
|
553
|
+
42
|
554
|
+
43
|
555
|
+
44
|
556
|
+
45
|
557
|
+
46
|
558
|
+
47
|
559
|
+
48</pre>
|
560
|
+
</td>
|
561
|
+
<td>
|
562
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 39</span>
|
563
|
+
|
564
|
+
<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>
|
565
|
+
<span class='kw'>return</span> <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span>
|
566
|
+
<span class='kw'>when</span> <span class='const'>Symbol</span><span class='comma'>,</span> <span class='const'>String</span>
|
567
|
+
<span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_valid_keys'>valid_keys</span><span class='period'>.</span><span class='id identifier rubyid_exclude?'>exclude?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span>
|
568
|
+
<span class='kw'>when</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span>
|
569
|
+
<span class='kw'>true</span>
|
570
|
+
<span class='kw'>else</span>
|
571
|
+
<span class='kw'>false</span>
|
572
|
+
<span class='kw'>end</span>
|
573
|
+
<span class='kw'>end</span></pre>
|
574
|
+
</td>
|
575
|
+
</tr>
|
576
|
+
</table>
|
577
|
+
</div>
|
578
|
+
|
579
|
+
<div class="method_details ">
|
580
|
+
<h3 class="signature " id="serialize-instance_method">
|
581
|
+
|
582
|
+
#<strong>serialize</strong>(value) ⇒ <tt>Object</tt>
|
583
|
+
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
</h3><div class="docstring">
|
589
|
+
<div class="discussion">
|
590
|
+
|
591
|
+
<p>This converts an Anchormodel instance to string for DB</p>
|
592
|
+
|
593
|
+
|
594
|
+
</div>
|
595
|
+
</div>
|
596
|
+
<div class="tags">
|
597
|
+
|
598
|
+
|
599
|
+
</div><table class="source_code">
|
600
|
+
<tr>
|
601
|
+
<td>
|
602
|
+
<pre class="lines">
|
603
|
+
|
604
|
+
|
605
|
+
22
|
606
|
+
23
|
607
|
+
24
|
608
|
+
25
|
609
|
+
26
|
610
|
+
27
|
611
|
+
28
|
612
|
+
29
|
613
|
+
30
|
614
|
+
31
|
615
|
+
32
|
616
|
+
33
|
617
|
+
34
|
618
|
+
35
|
619
|
+
36
|
620
|
+
37</pre>
|
621
|
+
</td>
|
622
|
+
<td>
|
623
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 22</span>
|
624
|
+
|
625
|
+
<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>
|
626
|
+
<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>
|
627
|
+
<span class='kw'>return</span> <span class='kw'>case</span> <span class='id identifier rubyid_value'>value</span>
|
628
|
+
<span class='kw'>when</span> <span class='const'>Symbol</span><span class='comma'>,</span> <span class='const'>String</span>
|
629
|
+
<span class='kw'>unless</span> <span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_valid_keys'>valid_keys</span><span class='period'>.</span><span class='id identifier rubyid_include?'>include?</span><span class='lparen'>(</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span><span class='rparen'>)</span>
|
630
|
+
<span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Attempt to set </span><span class='embexpr_beg'>#{</span><span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> to unsupported key </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'>.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
631
|
+
<span class='kw'>end</span>
|
632
|
+
<span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
633
|
+
<span class='kw'>when</span> <span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span>
|
634
|
+
<span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span>
|
635
|
+
<span class='kw'>when</span> <span class='kw'>nil</span>
|
636
|
+
<span class='kw'>nil</span>
|
637
|
+
<span class='kw'>else</span>
|
638
|
+
<span class='id identifier rubyid_fail'>fail</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Attempt to set </span><span class='embexpr_beg'>#{</span><span class='ivar'>@attribute</span><span class='period'>.</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'> to unsupported type </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_value'>value</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
639
|
+
<span class='kw'>end</span>
|
640
|
+
<span class='kw'>end</span></pre>
|
641
|
+
</td>
|
642
|
+
</tr>
|
643
|
+
</table>
|
644
|
+
</div>
|
645
|
+
|
646
|
+
<div class="method_details ">
|
647
|
+
<h3 class="signature " id="type-instance_method">
|
648
|
+
|
649
|
+
#<strong>type</strong> ⇒ <tt>Object</tt>
|
650
|
+
|
651
|
+
|
652
|
+
|
653
|
+
|
654
|
+
|
655
|
+
</h3><div class="docstring">
|
656
|
+
<div class="discussion">
|
657
|
+
|
658
|
+
|
659
|
+
</div>
|
660
|
+
</div>
|
661
|
+
<div class="tags">
|
662
|
+
|
663
|
+
|
664
|
+
</div><table class="source_code">
|
665
|
+
<tr>
|
666
|
+
<td>
|
667
|
+
<pre class="lines">
|
668
|
+
|
669
|
+
|
670
|
+
10
|
671
|
+
11
|
672
|
+
12</pre>
|
673
|
+
</td>
|
674
|
+
<td>
|
675
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/active_model_type_value_single.rb', line 10</span>
|
676
|
+
|
677
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_type'>type</span>
|
678
|
+
<span class='symbol'>:anchormodel</span>
|
679
|
+
<span class='kw'>end</span></pre>
|
680
|
+
</td>
|
681
|
+
</tr>
|
682
|
+
</table>
|
683
|
+
</div>
|
684
|
+
|
685
|
+
</div>
|
686
|
+
|
687
|
+
</div>
|
688
|
+
|
689
|
+
<div id="footer">
|
690
|
+
Generated on Sat Apr 27 10:18:33 2024 by
|
691
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
692
|
+
0.9.34 (ruby-3.2.2).
|
693
|
+
</div>
|
694
|
+
|
695
|
+
</div>
|
696
|
+
</body>
|
697
|
+
</html>
|