anchormodel 0.0.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.
@@ -0,0 +1,502 @@
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::Attribute
8
+
9
+ &mdash; Documentation by YARD 0.9.28
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::Attribute";
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> &raquo;
40
+ <span class='title'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span>
41
+ &raquo;
42
+ <span class="title">Attribute</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::Attribute
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">Anchormodel::Attribute</li>
78
+
79
+ </ul>
80
+ <a href="#" class="inheritanceTree">show all</a>
81
+
82
+ </dd>
83
+ </dl>
84
+
85
+
86
+
87
+
88
+
89
+
90
+
91
+
92
+
93
+
94
+
95
+ <dl>
96
+ <dt>Defined in:</dt>
97
+ <dd>lib/anchormodel/attribute.rb</dd>
98
+ </dl>
99
+
100
+ </div>
101
+
102
+ <h2>Overview</h2><div class="docstring">
103
+ <div class="discussion">
104
+ <p>This class holds all information related to a Rails model pointing to an Anchormodel.
105
+ It is instanciated when ModelMixin#belongs_to_anchormodel is used.</p>
106
+
107
+
108
+ </div>
109
+ </div>
110
+ <div class="tags">
111
+
112
+
113
+ </div>
114
+
115
+
116
+
117
+ <h2>Instance Attribute Summary <small><a href="#" class="summary_toggle">collapse</a></small></h2>
118
+ <ul class="summary">
119
+
120
+ <li class="public ">
121
+ <span class="summary_signature">
122
+
123
+ <a href="#attribute_name-instance_method" title="#attribute_name (instance method)">#<strong>attribute_name</strong> &#x21d2; Object </a>
124
+
125
+
126
+
127
+ </span>
128
+
129
+
130
+
131
+
132
+ <span class="note title readonly">readonly</span>
133
+
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+ <span class="summary_desc"><div class='inline'></div></span>
143
+
144
+ </li>
145
+
146
+
147
+ <li class="public ">
148
+ <span class="summary_signature">
149
+
150
+ <a href="#optional-instance_method" title="#optional (instance method)">#<strong>optional</strong> &#x21d2; Object </a>
151
+
152
+
153
+
154
+ </span>
155
+
156
+
157
+
158
+
159
+ <span class="note title readonly">readonly</span>
160
+
161
+
162
+
163
+
164
+
165
+
166
+
167
+
168
+
169
+ <span class="summary_desc"><div class='inline'></div></span>
170
+
171
+ </li>
172
+
173
+
174
+ </ul>
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 ">
188
+ <span class="summary_signature">
189
+
190
+ <a href="#anchor_class-instance_method" title="#anchor_class (instance method)">#<strong>anchor_class</strong> &#x21d2; Object </a>
191
+
192
+
193
+
194
+ </span>
195
+
196
+
197
+
198
+
199
+
200
+
201
+
202
+
203
+
204
+ <span class="summary_desc"><div class='inline'><p>Getter for the Anchormodel class based on the name passed to the initializer.</p>
205
+ </div></span>
206
+
207
+ </li>
208
+
209
+
210
+ <li class="public ">
211
+ <span class="summary_signature">
212
+
213
+ <a href="#initialize-instance_method" title="#initialize (instance method)">#<strong>initialize</strong>(model_class, attribute_name, anchor_class_name = nil, optional = false) &#x21d2; Attribute </a>
214
+
215
+
216
+
217
+ </span>
218
+
219
+
220
+ <span class="note title constructor">constructor</span>
221
+
222
+
223
+
224
+
225
+
226
+
227
+
228
+
229
+ <span class="summary_desc"><div class='inline'><p>A new instance of Attribute.</p>
230
+ </div></span>
231
+
232
+ </li>
233
+
234
+
235
+ </ul>
236
+
237
+
238
+ <div id="constructor_details" class="method_details_list">
239
+ <h2>Constructor Details</h2>
240
+
241
+ <div class="method_details first">
242
+ <h3 class="signature first" id="initialize-instance_method">
243
+
244
+ #<strong>initialize</strong>(model_class, attribute_name, anchor_class_name = nil, optional = false) &#x21d2; <tt><span class='object_link'><a href="" title="Anchormodel::Attribute (class)">Attribute</a></span></tt>
245
+
246
+
247
+
248
+
249
+
250
+ </h3><div class="docstring">
251
+ <div class="discussion">
252
+ <p>Returns a new instance of Attribute.</p>
253
+
254
+
255
+ </div>
256
+ </div>
257
+ <div class="tags">
258
+ <p class="tag_title">Parameters:</p>
259
+ <ul class="param">
260
+
261
+ <li>
262
+
263
+ <span class='name'>model_class</span>
264
+
265
+
266
+ <span class='type'>(<tt>ActiveRecord::Base</tt>)</span>
267
+
268
+
269
+
270
+ &mdash;
271
+ <div class='inline'><p>The Rails model where ModelMixin#belongs_to_anchormodel is used</p>
272
+ </div>
273
+
274
+ </li>
275
+
276
+ <li>
277
+
278
+ <span class='name'>attribute_name</span>
279
+
280
+
281
+ <span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
282
+
283
+
284
+
285
+ &mdash;
286
+ <div class='inline'><p>The name and database column of the attribute</p>
287
+ </div>
288
+
289
+ </li>
290
+
291
+ <li>
292
+
293
+ <span class='name'>anchor_class_name</span>
294
+
295
+
296
+ <span class='type'>(<tt>String</tt>)</span>
297
+
298
+
299
+ <em class="default">(defaults to: <tt>nil</tt>)</em>
300
+
301
+
302
+ &mdash;
303
+ <div class='inline'><p>Name of the Anchormodel class (omit if attribute <code>:foo_bar</code> holds an <code>Anchormodels::FooBar</code>)</p>
304
+ </div>
305
+
306
+ </li>
307
+
308
+ <li>
309
+
310
+ <span class='name'>optional</span>
311
+
312
+
313
+ <span class='type'>(<tt>Boolean</tt>)</span>
314
+
315
+
316
+ <em class="default">(defaults to: <tt>false</tt>)</em>
317
+
318
+
319
+ &mdash;
320
+ <div class='inline'><p>If true, a presence validation is added to the model.</p>
321
+ </div>
322
+
323
+ </li>
324
+
325
+ </ul>
326
+
327
+
328
+ </div><table class="source_code">
329
+ <tr>
330
+ <td>
331
+ <pre class="lines">
332
+
333
+
334
+ 12
335
+ 13
336
+ 14
337
+ 15
338
+ 16
339
+ 17</pre>
340
+ </td>
341
+ <td>
342
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 12</span>
343
+
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 rubyid_anchor_class_name'>anchor_class_name</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
+ <span class='ivar'>@model_class</span> <span class='op'>=</span> <span class='id identifier rubyid_model_class'>model_class</span>
346
+ <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'>@anchor_class_name</span> <span class='op'>=</span> <span class='id identifier rubyid_anchor_class_name'>anchor_class_name</span> <span class='op'>||</span> <span class='tstring'><span class='tstring_beg'>&quot;</span><span class='tstring_content'>Anchormodels::</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='period'>.</span><span class='id identifier rubyid_to_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='embexpr_end'>}</span><span class='tstring_end'>&quot;</span></span>
348
+ <span class='ivar'>@optional</span> <span class='op'>=</span> <span class='id identifier rubyid_optional'>optional</span>
349
+ <span class='kw'>end</span></pre>
350
+ </td>
351
+ </tr>
352
+ </table>
353
+ </div>
354
+
355
+ </div>
356
+
357
+ <div id="instance_attr_details" class="attr_details">
358
+ <h2>Instance Attribute Details</h2>
359
+
360
+
361
+ <span id=""></span>
362
+ <div class="method_details first">
363
+ <h3 class="signature first" id="attribute_name-instance_method">
364
+
365
+ #<strong>attribute_name</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
366
+
367
+
368
+
369
+
370
+
371
+ </h3><div class="docstring">
372
+ <div class="discussion">
373
+
374
+
375
+ </div>
376
+ </div>
377
+ <div class="tags">
378
+
379
+
380
+ </div><table class="source_code">
381
+ <tr>
382
+ <td>
383
+ <pre class="lines">
384
+
385
+
386
+ 5
387
+ 6
388
+ 7</pre>
389
+ </td>
390
+ <td>
391
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 5</span>
392
+
393
+ <span class='kw'>def</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span>
394
+ <span class='ivar'>@attribute_name</span>
395
+ <span class='kw'>end</span></pre>
396
+ </td>
397
+ </tr>
398
+ </table>
399
+ </div>
400
+
401
+
402
+ <span id=""></span>
403
+ <div class="method_details ">
404
+ <h3 class="signature " id="optional-instance_method">
405
+
406
+ #<strong>optional</strong> &#x21d2; <tt>Object</tt> <span class="extras">(readonly)</span>
407
+
408
+
409
+
410
+
411
+
412
+ </h3><div class="docstring">
413
+ <div class="discussion">
414
+
415
+
416
+ </div>
417
+ </div>
418
+ <div class="tags">
419
+
420
+
421
+ </div><table class="source_code">
422
+ <tr>
423
+ <td>
424
+ <pre class="lines">
425
+
426
+
427
+ 6
428
+ 7
429
+ 8</pre>
430
+ </td>
431
+ <td>
432
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 6</span>
433
+
434
+ <span class='kw'>def</span> <span class='id identifier rubyid_optional'>optional</span>
435
+ <span class='ivar'>@optional</span>
436
+ <span class='kw'>end</span></pre>
437
+ </td>
438
+ </tr>
439
+ </table>
440
+ </div>
441
+
442
+ </div>
443
+
444
+
445
+ <div id="instance_method_details" class="method_details_list">
446
+ <h2>Instance Method Details</h2>
447
+
448
+
449
+ <div class="method_details first">
450
+ <h3 class="signature first" id="anchor_class-instance_method">
451
+
452
+ #<strong>anchor_class</strong> &#x21d2; <tt>Object</tt>
453
+
454
+
455
+
456
+
457
+
458
+ </h3><div class="docstring">
459
+ <div class="discussion">
460
+ <p>Getter for the Anchormodel class based on the name passed to the initializer.
461
+ We are loading the anchor class lazily, because the model mixin instanciates this statically -&gt; avoid premature anchor class loading</p>
462
+
463
+
464
+ </div>
465
+ </div>
466
+ <div class="tags">
467
+
468
+
469
+ </div><table class="source_code">
470
+ <tr>
471
+ <td>
472
+ <pre class="lines">
473
+
474
+
475
+ 21
476
+ 22
477
+ 23</pre>
478
+ </td>
479
+ <td>
480
+ <pre class="code"><span class="info file"># File 'lib/anchormodel/attribute.rb', line 21</span>
481
+
482
+ <span class='kw'>def</span> <span class='id identifier rubyid_anchor_class'>anchor_class</span>
483
+ <span class='ivar'>@anchor_class</span> <span class='op'>||=</span> <span class='ivar'>@anchor_class_name</span><span class='period'>.</span><span class='id identifier rubyid_constantize'>constantize</span>
484
+ <span class='kw'>end</span></pre>
485
+ </td>
486
+ </tr>
487
+ </table>
488
+ </div>
489
+
490
+ </div>
491
+
492
+ </div>
493
+
494
+ <div id="footer">
495
+ Generated on Sat Dec 17 12:56:00 2022 by
496
+ <a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
497
+ 0.9.28 (ruby-3.0.4).
498
+ </div>
499
+
500
+ </div>
501
+ </body>
502
+ </html>