anchormodel 0.0.2 → 0.1.1
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 +11 -0
- data/Gemfile +3 -0
- data/Gemfile.lock +206 -0
- data/README.md +98 -9
- data/Rakefile +23 -3
- data/anchormodel.gemspec +26 -10
- data/bin/rails +7 -0
- data/doc/Anchormodel/ActiveModelTypeValue.html +14 -10
- data/doc/Anchormodel/Attribute.html +75 -71
- data/doc/Anchormodel/ModelMixin.html +190 -21
- data/doc/Anchormodel/Version.html +4 -4
- data/doc/Anchormodel.html +151 -53
- data/doc/_index.html +2 -2
- data/doc/file.README.html +118 -47
- data/doc/index.html +118 -47
- data/doc/method_list.html +9 -1
- data/doc/top-level-namespace.html +2 -2
- data/lib/anchormodel/active_model_type_value.rb +4 -4
- data/lib/anchormodel/attribute.rb +4 -9
- data/lib/anchormodel/model_mixin.rb +53 -3
- data/lib/anchormodel/version.rb +2 -2
- data/lib/anchormodel.rb +7 -2
- data/logo.svg +98 -0
- data/test/active_record_model/user_test.rb +115 -0
- data/test/dummy/.gitignore +29 -0
- data/test/dummy/Rakefile +6 -0
- data/test/dummy/app/anchormodels/locale.rb +6 -0
- data/test/dummy/app/anchormodels/role.rb +14 -0
- data/test/dummy/app/helpers/application_helper.rb +2 -0
- data/test/dummy/app/models/application_record.rb +5 -0
- data/test/dummy/app/models/concerns/.keep +0 -0
- data/test/dummy/app/models/user.rb +6 -0
- data/test/dummy/bin/rails +4 -0
- data/test/dummy/bin/rake +4 -0
- data/test/dummy/bin/setup +33 -0
- data/test/dummy/config/application.rb +37 -0
- data/test/dummy/config/boot.rb +3 -0
- data/test/dummy/config/credentials.yml.enc +1 -0
- data/test/dummy/config/database.yml +8 -0
- data/test/dummy/config/environment.rb +5 -0
- data/test/dummy/config/environments/test.rb +50 -0
- data/test/dummy/config/initializers/content_security_policy.rb +25 -0
- data/test/dummy/config/initializers/filter_parameter_logging.rb +8 -0
- data/test/dummy/config/initializers/inflections.rb +16 -0
- data/test/dummy/config/initializers/permissions_policy.rb +11 -0
- data/test/dummy/config/locales/en.yml +33 -0
- data/test/dummy/config/puma.rb +43 -0
- data/test/dummy/config/routes.rb +6 -0
- data/test/dummy/config.ru +6 -0
- data/test/dummy/db/migrate/20230107173151_create_users.rb +12 -0
- data/test/dummy/db/schema.rb +23 -0
- data/test/dummy/db/seeds.rb +7 -0
- data/test/dummy/lib/tasks/.keep +0 -0
- data/test/dummy/log/.keep +0 -0
- data/test/dummy/tmp/.keep +0 -0
- data/test/dummy/tmp/pids/.keep +0 -0
- data/test/test_helper.rb +21 -0
- metadata +149 -13
- data/anchormodel-0.0.1.gem +0 -0
@@ -101,8 +101,8 @@
|
|
101
101
|
|
102
102
|
<h2>Overview</h2><div class="docstring">
|
103
103
|
<div class="discussion">
|
104
|
-
|
105
|
-
It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
104
|
+
|
105
|
+
<p>This class holds all information related to a Rails model pointing to an Anchormodel. It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
106
106
|
|
107
107
|
|
108
108
|
</div>
|
@@ -120,7 +120,7 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
120
120
|
<li class="public ">
|
121
121
|
<span class="summary_signature">
|
122
122
|
|
123
|
-
<a href="#
|
123
|
+
<a href="#anchormodel_class-instance_method" title="#anchormodel_class (instance method)">#<strong>anchormodel_class</strong> ⇒ Object </a>
|
124
124
|
|
125
125
|
|
126
126
|
|
@@ -147,7 +147,7 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
147
147
|
<li class="public ">
|
148
148
|
<span class="summary_signature">
|
149
149
|
|
150
|
-
<a href="#
|
150
|
+
<a href="#attribute_name-instance_method" title="#attribute_name (instance method)">#<strong>attribute_name</strong> ⇒ Object </a>
|
151
151
|
|
152
152
|
|
153
153
|
|
@@ -171,23 +171,10 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
171
171
|
</li>
|
172
172
|
|
173
173
|
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
<h2>
|
181
|
-
Instance Method Summary
|
182
|
-
<small><a href="#" class="summary_toggle">collapse</a></small>
|
183
|
-
</h2>
|
184
|
-
|
185
|
-
<ul class="summary">
|
186
|
-
|
187
|
-
<li class="public ">
|
174
|
+
<li class="public ">
|
188
175
|
<span class="summary_signature">
|
189
176
|
|
190
|
-
<a href="#
|
177
|
+
<a href="#optional-instance_method" title="#optional (instance method)">#<strong>optional</strong> ⇒ Object </a>
|
191
178
|
|
192
179
|
|
193
180
|
|
@@ -195,22 +182,39 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
195
182
|
|
196
183
|
|
197
184
|
|
185
|
+
|
186
|
+
<span class="note title readonly">readonly</span>
|
187
|
+
|
188
|
+
|
189
|
+
|
198
190
|
|
199
191
|
|
200
192
|
|
201
193
|
|
202
194
|
|
203
195
|
|
204
|
-
<span class="summary_desc"><div class='inline'
|
205
|
-
</div></span>
|
196
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
206
197
|
|
207
198
|
</li>
|
208
199
|
|
200
|
+
|
201
|
+
</ul>
|
202
|
+
|
203
|
+
|
204
|
+
|
205
|
+
|
206
|
+
|
207
|
+
<h2>
|
208
|
+
Instance Method Summary
|
209
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
210
|
+
</h2>
|
211
|
+
|
212
|
+
<ul class="summary">
|
209
213
|
|
210
214
|
<li class="public ">
|
211
215
|
<span class="summary_signature">
|
212
216
|
|
213
|
-
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(model_class, attribute_name,
|
217
|
+
<a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(model_class, attribute_name, anchormodel_class = nil, optional = false) ⇒ Attribute </a>
|
214
218
|
|
215
219
|
|
216
220
|
|
@@ -226,7 +230,8 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
226
230
|
|
227
231
|
|
228
232
|
|
229
|
-
<span class="summary_desc"><div class='inline'
|
233
|
+
<span class="summary_desc"><div class='inline'>
|
234
|
+
<p>A new instance of Attribute.</p>
|
230
235
|
</div></span>
|
231
236
|
|
232
237
|
</li>
|
@@ -241,7 +246,7 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
241
246
|
<div class="method_details first">
|
242
247
|
<h3 class="signature first" id="initialize-instance_method">
|
243
248
|
|
244
|
-
#<strong>initialize</strong>(model_class, attribute_name,
|
249
|
+
#<strong>initialize</strong>(model_class, attribute_name, anchormodel_class = nil, optional = false) ⇒ <tt><span class='object_link'><a href="" title="Anchormodel::Attribute (class)">Attribute</a></span></tt>
|
245
250
|
|
246
251
|
|
247
252
|
|
@@ -249,7 +254,8 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
249
254
|
|
250
255
|
</h3><div class="docstring">
|
251
256
|
<div class="discussion">
|
252
|
-
|
257
|
+
|
258
|
+
<p>Returns a new instance of Attribute.</p>
|
253
259
|
|
254
260
|
|
255
261
|
</div>
|
@@ -268,7 +274,8 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
268
274
|
|
269
275
|
|
270
276
|
—
|
271
|
-
<div class='inline'
|
277
|
+
<div class='inline'>
|
278
|
+
<p>The Rails model where ModelMixin#belongs_to_anchormodel is used</p>
|
272
279
|
</div>
|
273
280
|
|
274
281
|
</li>
|
@@ -283,24 +290,26 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
283
290
|
|
284
291
|
|
285
292
|
—
|
286
|
-
<div class='inline'
|
293
|
+
<div class='inline'>
|
294
|
+
<p>The name and database column of the attribute</p>
|
287
295
|
</div>
|
288
296
|
|
289
297
|
</li>
|
290
298
|
|
291
299
|
<li>
|
292
300
|
|
293
|
-
<span class='name'>
|
301
|
+
<span class='name'>anchormodel_class</span>
|
294
302
|
|
295
303
|
|
296
|
-
<span class='type'>(<tt>
|
304
|
+
<span class='type'>(<tt>Class</tt>)</span>
|
297
305
|
|
298
306
|
|
299
307
|
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
300
308
|
|
301
309
|
|
302
310
|
—
|
303
|
-
<div class='inline'
|
311
|
+
<div class='inline'>
|
312
|
+
<p>Class of the Anchormodel (omit if attribute <code>:foo_bar</code> holds an <code>FooBar</code>)</p>
|
304
313
|
</div>
|
305
314
|
|
306
315
|
</li>
|
@@ -317,7 +326,8 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
317
326
|
|
318
327
|
|
319
328
|
—
|
320
|
-
<div class='inline'
|
329
|
+
<div class='inline'>
|
330
|
+
<p>If true, a presence validation is added to the model.</p>
|
321
331
|
</div>
|
322
332
|
|
323
333
|
</li>
|
@@ -331,20 +341,20 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
331
341
|
<pre class="lines">
|
332
342
|
|
333
343
|
|
334
|
-
12
|
335
344
|
13
|
336
345
|
14
|
337
346
|
15
|
338
347
|
16
|
339
|
-
17
|
348
|
+
17
|
349
|
+
18</pre>
|
340
350
|
</td>
|
341
351
|
<td>
|
342
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line
|
352
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 13</span>
|
343
353
|
|
344
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier
|
354
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_initialize'>initialize</span><span class='lparen'>(</span><span class='id identifier rubyid_model_class'>model_class</span><span class='comma'>,</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span> <span class='op'>=</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='id identifier rubyid_optional'>optional</span> <span class='op'>=</span> <span class='kw'>false</span><span class='rparen'>)</span>
|
345
355
|
<span class='ivar'>@model_class</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span>
|
346
356
|
<span class='ivar'>@attribute_name</span> <span class='op'>=</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
|
347
|
-
<span class='ivar'>@
|
357
|
+
<span class='ivar'>@anchormodel_class</span> <span class='op'>=</span> <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span>
|
348
358
|
<span class='ivar'>@optional</span> <span class='op'>=</span> <span class='id identifier rubyid_optional'>optional</span>
|
349
359
|
<span class='kw'>end</span></pre>
|
350
360
|
</td>
|
@@ -360,9 +370,9 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
360
370
|
|
361
371
|
<span id=""></span>
|
362
372
|
<div class="method_details first">
|
363
|
-
<h3 class="signature first" id="
|
373
|
+
<h3 class="signature first" id="anchormodel_class-instance_method">
|
364
374
|
|
365
|
-
#<strong>
|
375
|
+
#<strong>anchormodel_class</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
366
376
|
|
367
377
|
|
368
378
|
|
@@ -383,15 +393,15 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
383
393
|
<pre class="lines">
|
384
394
|
|
385
395
|
|
386
|
-
5
|
387
396
|
6
|
388
|
-
7
|
397
|
+
7
|
398
|
+
8</pre>
|
389
399
|
</td>
|
390
400
|
<td>
|
391
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line
|
401
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 6</span>
|
392
402
|
|
393
|
-
<span class='kw'>def</span> <span class='id identifier
|
394
|
-
<span class='ivar'>@
|
403
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span>
|
404
|
+
<span class='ivar'>@anchormodel_class</span>
|
395
405
|
<span class='kw'>end</span></pre>
|
396
406
|
</td>
|
397
407
|
</tr>
|
@@ -401,9 +411,9 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
401
411
|
|
402
412
|
<span id=""></span>
|
403
413
|
<div class="method_details ">
|
404
|
-
<h3 class="signature " id="
|
414
|
+
<h3 class="signature " id="attribute_name-instance_method">
|
405
415
|
|
406
|
-
#<strong>
|
416
|
+
#<strong>attribute_name</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
407
417
|
|
408
418
|
|
409
419
|
|
@@ -424,32 +434,27 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
424
434
|
<pre class="lines">
|
425
435
|
|
426
436
|
|
437
|
+
5
|
427
438
|
6
|
428
|
-
7
|
429
|
-
8</pre>
|
439
|
+
7</pre>
|
430
440
|
</td>
|
431
441
|
<td>
|
432
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line
|
442
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 5</span>
|
433
443
|
|
434
|
-
<span class='kw'>def</span> <span class='id identifier
|
435
|
-
<span class='ivar'>@
|
444
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span>
|
445
|
+
<span class='ivar'>@attribute_name</span>
|
436
446
|
<span class='kw'>end</span></pre>
|
437
447
|
</td>
|
438
448
|
</tr>
|
439
449
|
</table>
|
440
450
|
</div>
|
441
451
|
|
442
|
-
|
443
|
-
|
444
|
-
|
445
|
-
<
|
446
|
-
<h2>Instance Method Details</h2>
|
447
|
-
|
448
|
-
|
449
|
-
<div class="method_details first">
|
450
|
-
<h3 class="signature first" id="anchor_class-instance_method">
|
452
|
+
|
453
|
+
<span id=""></span>
|
454
|
+
<div class="method_details ">
|
455
|
+
<h3 class="signature " id="optional-instance_method">
|
451
456
|
|
452
|
-
#<strong>
|
457
|
+
#<strong>optional</strong> ⇒ <tt>Object</tt> <span class="extras">(readonly)</span>
|
453
458
|
|
454
459
|
|
455
460
|
|
@@ -457,9 +462,7 @@ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
|
|
457
462
|
|
458
463
|
</h3><div class="docstring">
|
459
464
|
<div class="discussion">
|
460
|
-
|
461
|
-
We are loading the anchor class lazily, because the model mixin instanciates this statically -> avoid premature anchor class loading</p>
|
462
|
-
|
465
|
+
|
463
466
|
|
464
467
|
</div>
|
465
468
|
</div>
|
@@ -472,15 +475,15 @@ We are loading the anchor class lazily, because the model mixin instanciates thi
|
|
472
475
|
<pre class="lines">
|
473
476
|
|
474
477
|
|
475
|
-
|
476
|
-
|
477
|
-
|
478
|
+
7
|
479
|
+
8
|
480
|
+
9</pre>
|
478
481
|
</td>
|
479
482
|
<td>
|
480
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line
|
483
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 7</span>
|
481
484
|
|
482
|
-
<span class='kw'>def</span> <span class='id identifier
|
483
|
-
<span class='ivar'>@
|
485
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_optional'>optional</span>
|
486
|
+
<span class='ivar'>@optional</span>
|
484
487
|
<span class='kw'>end</span></pre>
|
485
488
|
</td>
|
486
489
|
</tr>
|
@@ -489,12 +492,13 @@ We are loading the anchor class lazily, because the model mixin instanciates thi
|
|
489
492
|
|
490
493
|
</div>
|
491
494
|
|
495
|
+
|
492
496
|
</div>
|
493
497
|
|
494
498
|
<div id="footer">
|
495
|
-
Generated on
|
499
|
+
Generated on Tue Jan 24 20:27:59 2023 by
|
496
500
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
497
|
-
0.9.28 (ruby-3.
|
501
|
+
0.9.28 (ruby-3.1.3).
|
498
502
|
</div>
|
499
503
|
|
500
504
|
</div>
|