anchormodel 0.1.2 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +9 -0
- data/Gemfile.lock +26 -24
- data/README.md +8 -0
- data/VERSION +1 -0
- data/anchormodel.gemspec +16 -31
- data/doc/Anchormodel/Attribute.html +3 -3
- data/doc/Anchormodel/ModelMixin.html +19 -284
- data/doc/Anchormodel/Version.html +4 -60
- data/doc/Anchormodel.html +5 -5
- data/doc/_index.html +25 -5
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +14 -6
- data/doc/frames.html +10 -5
- data/doc/index.html +14 -6
- data/doc/method_list.html +43 -19
- data/doc/top-level-namespace.html +4 -4
- data/lib/anchormodel/{active_model_type_value.rb → active_model_type_value_single.rb} +22 -9
- data/lib/anchormodel/model_mixin.rb +4 -82
- data/lib/anchormodel/util.rb +93 -0
- data/lib/anchormodel/version.rb +1 -7
- data/lib/anchormodel.rb +2 -1
- data/lib/generators/anchormodel/USAGE +8 -0
- data/lib/generators/anchormodel/anchormodel_generator.rb +11 -0
- data/lib/generators/anchormodel/templates/anchormodel.rb.erb +3 -0
- data/pkg/anchormodel-0.1.3.gem +0 -0
- data/test/active_record_model/user_test.rb +19 -0
- metadata +15 -9
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Anchormodel::ModelMixin
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.36
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -117,7 +117,7 @@
|
|
117
117
|
<li class="public ">
|
118
118
|
<span class="summary_signature">
|
119
119
|
|
120
|
-
<a href="#belongs_to_anchormodel-class_method" title="belongs_to_anchormodel (class method)">.<strong>belongs_to_anchormodel</strong>(
|
120
|
+
<a href="#belongs_to_anchormodel-class_method" title="belongs_to_anchormodel (class method)">.<strong>belongs_to_anchormodel</strong>(*args, **kwargs) ⇒ Object </a>
|
121
121
|
|
122
122
|
|
123
123
|
|
@@ -151,7 +151,7 @@
|
|
151
151
|
<div class="method_details first">
|
152
152
|
<h3 class="signature first" id="belongs_to_anchormodel-class_method">
|
153
153
|
|
154
|
-
.<strong>belongs_to_anchormodel</strong>(
|
154
|
+
.<strong>belongs_to_anchormodel</strong>(*args, **kwargs) ⇒ <tt>Object</tt>
|
155
155
|
|
156
156
|
|
157
157
|
|
@@ -160,141 +160,20 @@
|
|
160
160
|
</h3><div class="docstring">
|
161
161
|
<div class="discussion">
|
162
162
|
|
163
|
-
<p>Creates an attribute linking to an Anchormodel. The attribute should be present in the DB and the column should be named the same as <code>attribute_name
|
163
|
+
<p>Creates an attribute linking to an Anchormodel. The attribute should be present in the DB and the column should be of type String and named the same as <code>attribute_name</code>.</p>
|
164
164
|
|
165
165
|
|
166
166
|
</div>
|
167
167
|
</div>
|
168
168
|
<div class="tags">
|
169
|
-
<p class="tag_title">Parameters:</p>
|
170
|
-
<ul class="param">
|
171
169
|
|
172
|
-
<li>
|
173
|
-
|
174
|
-
<span class='name'>attribute_name</span>
|
175
|
-
|
176
|
-
|
177
|
-
<span class='type'>(<tt>String</tt>, <tt>Symbol</tt>)</span>
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
—
|
182
|
-
<div class='inline'>
|
183
|
-
<p>The name and database column of the attribute</p>
|
184
|
-
</div>
|
185
|
-
|
186
|
-
</li>
|
187
|
-
|
188
|
-
<li>
|
189
|
-
|
190
|
-
<span class='name'>anchormodel_class</span>
|
191
|
-
|
192
|
-
|
193
|
-
<span class='type'>(<tt>Class</tt>)</span>
|
194
|
-
|
195
|
-
|
196
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
197
|
-
|
198
|
-
|
199
|
-
—
|
200
|
-
<div class='inline'>
|
201
|
-
<p>Class of the Anchormodel (omit if attribute <code>:foo_bar</code> holds a <code>FooBar</code>)</p>
|
202
|
-
</div>
|
203
|
-
|
204
|
-
</li>
|
205
|
-
|
206
|
-
<li>
|
207
|
-
|
208
|
-
<span class='name'>optional</span>
|
209
|
-
|
210
|
-
|
211
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
212
|
-
|
213
|
-
|
214
|
-
<em class="default">(defaults to: <tt>false</tt>)</em>
|
215
|
-
|
216
|
-
|
217
|
-
—
|
218
|
-
<div class='inline'>
|
219
|
-
<p>If true, a presence validation is added to the model.</p>
|
220
|
-
</div>
|
221
|
-
|
222
|
-
</li>
|
223
|
-
|
224
|
-
<li>
|
225
|
-
|
226
|
-
<span class='name'>model_readers</span>
|
227
|
-
|
228
|
-
|
229
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
230
|
-
|
231
|
-
|
232
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
233
|
-
|
234
|
-
|
235
|
-
—
|
236
|
-
<div class='inline'>
|
237
|
-
<p>If true, the model is given an ActiveRecord::Enum style method <code>my_model.my_key?</code> reader for each key in the anchormodel</p>
|
238
|
-
</div>
|
239
|
-
|
240
|
-
</li>
|
241
|
-
|
242
|
-
<li>
|
243
|
-
|
244
|
-
<span class='name'>model_writers</span>
|
245
|
-
|
246
|
-
|
247
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
248
|
-
|
249
|
-
|
250
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
251
|
-
|
252
|
-
|
253
|
-
—
|
254
|
-
<div class='inline'>
|
255
|
-
<p>If true, the model is given an ActiveRecord::Enum style method <code>my_model.my_key!</code> writer for each key in the anchormodel</p>
|
256
|
-
</div>
|
257
|
-
|
258
|
-
</li>
|
259
|
-
|
260
|
-
<li>
|
261
|
-
|
262
|
-
<span class='name'>model_scopes</span>
|
263
|
-
|
264
|
-
|
265
|
-
<span class='type'>(<tt>Boolean</tt>)</span>
|
266
|
-
|
267
|
-
|
268
|
-
<em class="default">(defaults to: <tt>true</tt>)</em>
|
269
|
-
|
270
|
-
|
271
|
-
—
|
272
|
-
<div class='inline'>
|
273
|
-
<p>If true, the model is given an ActiveRecord::Enum style scope <code>MyModel.mykey</code> for each key in the anchormodel</p>
|
274
|
-
</div>
|
275
|
-
|
276
|
-
</li>
|
277
|
-
|
278
|
-
<li>
|
279
|
-
|
280
|
-
<span class='name'>model_methods</span>
|
281
|
-
|
282
|
-
|
283
|
-
<span class='type'>(<tt>Boolean</tt>, <tt>NilClass</tt>)</span>
|
284
|
-
|
285
|
-
|
286
|
-
<em class="default">(defaults to: <tt>nil</tt>)</em>
|
287
|
-
|
288
|
-
|
289
|
-
—
|
290
|
-
<div class='inline'>
|
291
|
-
<p>If non-nil, this mass-assigns and overrides <code>model_readers</code>, <code>model_writers</code> and <code>model_scopes</code></p>
|
292
|
-
</div>
|
293
|
-
|
294
|
-
</li>
|
295
|
-
|
296
|
-
</ul>
|
297
170
|
|
171
|
+
<p class="tag_title">See Also:</p>
|
172
|
+
<ul class="see">
|
173
|
+
|
174
|
+
<li>Parameters</li>
|
175
|
+
|
176
|
+
</ul>
|
298
177
|
|
299
178
|
</div><table class="source_code">
|
300
179
|
<tr>
|
@@ -302,159 +181,15 @@
|
|
302
181
|
<pre class="lines">
|
303
182
|
|
304
183
|
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
23
|
309
|
-
24
|
310
|
-
25
|
311
|
-
26
|
312
|
-
27
|
313
|
-
28
|
314
|
-
29
|
315
|
-
30
|
316
|
-
31
|
317
|
-
32
|
318
|
-
33
|
319
|
-
34
|
320
|
-
35
|
321
|
-
36
|
322
|
-
37
|
323
|
-
38
|
324
|
-
39
|
325
|
-
40
|
326
|
-
41
|
327
|
-
42
|
328
|
-
43
|
329
|
-
44
|
330
|
-
45
|
331
|
-
46
|
332
|
-
47
|
333
|
-
48
|
334
|
-
49
|
335
|
-
50
|
336
|
-
51
|
337
|
-
52
|
338
|
-
53
|
339
|
-
54
|
340
|
-
55
|
341
|
-
56
|
342
|
-
57
|
343
|
-
58
|
344
|
-
59
|
345
|
-
60
|
346
|
-
61
|
347
|
-
62
|
348
|
-
63
|
349
|
-
64
|
350
|
-
65
|
351
|
-
66
|
352
|
-
67
|
353
|
-
68
|
354
|
-
69
|
355
|
-
70
|
356
|
-
71
|
357
|
-
72
|
358
|
-
73
|
359
|
-
74
|
360
|
-
75
|
361
|
-
76
|
362
|
-
77
|
363
|
-
78
|
364
|
-
79
|
365
|
-
80
|
366
|
-
81
|
367
|
-
82
|
368
|
-
83
|
369
|
-
84
|
370
|
-
85
|
371
|
-
86
|
372
|
-
87
|
373
|
-
88
|
374
|
-
89
|
375
|
-
90
|
376
|
-
91
|
377
|
-
92
|
378
|
-
93
|
379
|
-
94</pre>
|
184
|
+
14
|
185
|
+
15
|
186
|
+
16</pre>
|
380
187
|
</td>
|
381
188
|
<td>
|
382
|
-
<pre class="code"><span class="info file"># File 'lib/anchormodel/model_mixin.rb', line
|
383
|
-
|
384
|
-
<span class='kw'>def</span> <span class='id identifier rubyid_belongs_to_anchormodel'>belongs_to_anchormodel</span><span class='lparen'>(</span><span class='
|
385
|
-
|
386
|
-
<span class='id identifier rubyid_anchormodel_class'>anchormodel_class</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_s'>to_s</span><span class='period'>.</span><span class='id identifier rubyid_classify'>classify</span><span class='period'>.</span><span class='id identifier rubyid_constantize'>constantize</span>
|
387
|
-
<span class='id identifier rubyid_attribute_name'>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>
|
388
|
-
<span class='id identifier rubyid_attribute'>attribute</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="Attribute.html#initialize-instance_method" title="Anchormodel::Attribute#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='kw'>self</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='comma'>,</span> <span class='id identifier rubyid_optional'>optional</span><span class='rparen'>)</span>
|
389
|
-
|
390
|
-
<span class='comment'># Mass configurations if model_methods was specfied
|
391
|
-
</span> <span class='kw'>unless</span> <span class='id identifier rubyid_model_methods'>model_methods</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span>
|
392
|
-
<span class='id identifier rubyid_model_readers'>model_readers</span> <span class='op'>=</span> <span class='id identifier rubyid_model_methods'>model_methods</span>
|
393
|
-
<span class='id identifier rubyid_model_writers'>model_writers</span> <span class='op'>=</span> <span class='id identifier rubyid_model_methods'>model_methods</span>
|
394
|
-
<span class='id identifier rubyid_model_scopes'>model_scopes</span> <span class='op'>=</span> <span class='id identifier rubyid_model_methods'>model_methods</span>
|
395
|
-
<span class='kw'>end</span>
|
396
|
-
|
397
|
-
<span class='comment'># Register attribute
|
398
|
-
</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_attributes'>anchormodel_attributes</span> <span class='op'>=</span> <span class='id identifier rubyid_anchormodel_attributes'>anchormodel_attributes</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='lbrace'>{</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span> <span class='op'>=></span> <span class='id identifier rubyid_attribute'>attribute</span> <span class='rbrace'>}</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_freeze'>freeze</span>
|
399
|
-
|
400
|
-
<span class='comment'># Add presence validation if required
|
401
|
-
</span> <span class='kw'>unless</span> <span class='id identifier rubyid_optional'>optional</span>
|
402
|
-
<span class='id identifier rubyid_validates'>validates</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='label'>presence:</span> <span class='kw'>true</span>
|
403
|
-
<span class='kw'>end</span>
|
404
|
-
|
405
|
-
<span class='comment'># Make casting work
|
406
|
-
</span> <span class='comment'># Define serializer/deserializer
|
407
|
-
</span> <span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="ActiveModelTypeValue.html" title="Anchormodel::ActiveModelTypeValue (class)">ActiveModelTypeValue</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="ActiveModelTypeValue.html#initialize-instance_method" title="Anchormodel::ActiveModelTypeValue#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='id identifier rubyid_attribute'>attribute</span><span class='rparen'>)</span>
|
408
|
-
|
409
|
-
<span class='comment'># Overwrite reader to force building anchors at every retrieval
|
410
|
-
</span> <span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</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='rparen'>)</span> <span class='kw'>do</span>
|
411
|
-
<span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span><span class='period'>.</span><span class='id identifier rubyid_deserialize'>deserialize</span><span class='lparen'>(</span><span class='id identifier rubyid_read_attribute'>read_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
412
|
-
<span class='kw'>end</span>
|
413
|
-
|
414
|
-
<span class='comment'># Override writer to fail early when an invalid target value is specified
|
415
|
-
</span> <span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>=</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span> <span class='op'>|</span><span class='id identifier rubyid_new_value'>new_value</span><span class='op'>|</span>
|
416
|
-
<span class='id identifier rubyid_write_attribute'>write_attribute</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_new_value'>new_value</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
417
|
-
<span class='kw'>end</span>
|
418
|
-
|
419
|
-
<span class='comment'># Supply serializer and deserializer
|
420
|
-
</span> <span class='id identifier rubyid_attribute'>attribute</span> <span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='comma'>,</span> <span class='id identifier rubyid_active_model_type_value'>active_model_type_value</span>
|
421
|
-
|
422
|
-
<span class='comment'># Create ActiveRecord::Enum style reader directly in the model if asked to do so
|
423
|
-
</span> <span class='comment'># For a model User with anchormodel Role with keys :admin and :guest, this creates user.admin? and user.guest? (returning true iff role is admin/guest)
|
424
|
-
</span> <span class='kw'>if</span> <span class='id identifier rubyid_model_readers'>model_readers</span>
|
425
|
-
<span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</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_entry'>entry</span><span class='op'>|</span>
|
426
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:"#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>?</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
427
|
-
<span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Anchormodel reader </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>? already defined for </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'>, add `model_readers: false` to `belongs_to_anchormodel :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>`.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
428
|
-
<span class='kw'>end</span>
|
429
|
-
<span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='symbol'>:"#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>?</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
|
430
|
-
<span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</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='rparen'>)</span> <span class='op'>==</span> <span class='id identifier rubyid_entry'>entry</span>
|
431
|
-
<span class='kw'>end</span>
|
432
|
-
<span class='kw'>end</span>
|
433
|
-
<span class='kw'>end</span>
|
434
|
-
|
435
|
-
<span class='comment'># Create ActiveRecord::Enum style writer directly in the model if asked to do so
|
436
|
-
</span> <span class='comment'># For a model User with anchormodel Role with keys :admin and :guest, this creates user.admin! and user.guest! (setting the role to admin/guest)
|
437
|
-
</span> <span class='kw'>if</span> <span class='id identifier rubyid_model_writers'>model_writers</span>
|
438
|
-
<span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</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_entry'>entry</span><span class='op'>|</span>
|
439
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='symbol'>:"#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>!</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
440
|
-
<span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Anchormodel writer </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>! already defined for </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'>, add `model_writers: false` to `belongs_to_anchormodel :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>`.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
441
|
-
<span class='kw'>end</span>
|
442
|
-
<span class='id identifier rubyid_define_method'>define_method</span><span class='lparen'>(</span><span class='symbol'>:"#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'>!</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span> <span class='kw'>do</span>
|
443
|
-
<span class='id identifier rubyid_public_send'>public_send</span><span class='lparen'>(</span><span class='symbol'>:"#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</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_entry'>entry</span><span class='rparen'>)</span>
|
444
|
-
<span class='kw'>end</span>
|
445
|
-
<span class='kw'>end</span>
|
446
|
-
<span class='kw'>end</span>
|
447
|
-
|
448
|
-
<span class='comment'># Create ActiveRecord::Enum style scope directly in the model class if asked to do so
|
449
|
-
</span> <span class='comment'># For a model User with anchormodel Role with keys :admin and :guest, this creates user.admin! and user.guest! (setting the role to admin/guest)
|
450
|
-
</span> <span class='kw'>if</span> <span class='id identifier rubyid_model_scopes'>model_scopes</span>
|
451
|
-
<span class='id identifier rubyid_anchormodel_class'>anchormodel_class</span><span class='period'>.</span><span class='id identifier rubyid_all'>all</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_entry'>entry</span><span class='op'>|</span>
|
452
|
-
<span class='kw'>if</span> <span class='id identifier rubyid_respond_to?'>respond_to?</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span>
|
453
|
-
<span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Anchormodel scope </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='embexpr_end'>}</span><span class='tstring_content'> already defined for </span><span class='embexpr_beg'>#{</span><span class='kw'>self</span><span class='embexpr_end'>}</span><span class='tstring_content'>, add `model_scopes: false` to `belongs_to_anchormodel :</span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_attribute_name'>attribute_name</span><span class='embexpr_end'>}</span><span class='tstring_content'>`.</span><span class='tstring_end'>"</span></span><span class='rparen'>)</span>
|
454
|
-
<span class='kw'>end</span>
|
455
|
-
<span class='id identifier rubyid_scope'>scope</span><span class='lparen'>(</span><span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='comma'>,</span> <span class='tlambda'>-></span> <span class='tlambeg'>{</span> <span class='id identifier rubyid_where'>where</span><span class='lparen'>(</span><span class='id identifier rubyid_attribute_name'>attribute_name</span> <span class='op'>=></span> <span class='id identifier rubyid_entry'>entry</span><span class='period'>.</span><span class='id identifier rubyid_key'>key</span><span class='rparen'>)</span> <span class='rbrace'>}</span><span class='rparen'>)</span>
|
456
|
-
<span class='kw'>end</span>
|
457
|
-
<span class='kw'>end</span>
|
189
|
+
<pre class="code"><span class="info file"># File 'lib/anchormodel/model_mixin.rb', line 14</span>
|
190
|
+
|
191
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_belongs_to_anchormodel'>belongs_to_anchormodel</span><span class='lparen'>(</span><span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
192
|
+
<span class='const'><span class='object_link'><a href="../Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Util.html" title="Anchormodel::Util (module)">Util</a></span></span><span class='period'>.</span><span class='id identifier rubyid_install_methods_in_model'><span class='object_link'><a href="Util.html#install_methods_in_model-class_method" title="Anchormodel::Util.install_methods_in_model (method)">install_methods_in_model</a></span></span><span class='lparen'>(</span><span class='kw'>self</span><span class='comma'>,</span> <span class='op'>*</span><span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
458
193
|
<span class='kw'>end</span></pre>
|
459
194
|
</td>
|
460
195
|
</tr>
|
@@ -466,9 +201,9 @@
|
|
466
201
|
</div>
|
467
202
|
|
468
203
|
<div id="footer">
|
469
|
-
Generated on
|
204
|
+
Generated on Tue Apr 23 17:20:43 2024 by
|
470
205
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
471
|
-
0.9.
|
206
|
+
0.9.36 (ruby-3.2.2).
|
472
207
|
</div>
|
473
208
|
|
474
209
|
</div>
|
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Anchormodel::Version
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.36
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -101,62 +101,6 @@
|
|
101
101
|
|
102
102
|
<dl class="constants">
|
103
103
|
|
104
|
-
<dt id="MAJOR-constant" class="">MAJOR =
|
105
|
-
<div class="docstring">
|
106
|
-
<div class="discussion">
|
107
|
-
|
108
|
-
|
109
|
-
</div>
|
110
|
-
</div>
|
111
|
-
<div class="tags">
|
112
|
-
|
113
|
-
|
114
|
-
</div>
|
115
|
-
</dt>
|
116
|
-
<dd><pre class="code"><span class='int'>0</span></pre></dd>
|
117
|
-
|
118
|
-
<dt id="MINOR-constant" class="">MINOR =
|
119
|
-
<div class="docstring">
|
120
|
-
<div class="discussion">
|
121
|
-
|
122
|
-
|
123
|
-
</div>
|
124
|
-
</div>
|
125
|
-
<div class="tags">
|
126
|
-
|
127
|
-
|
128
|
-
</div>
|
129
|
-
</dt>
|
130
|
-
<dd><pre class="code"><span class='int'>1</span></pre></dd>
|
131
|
-
|
132
|
-
<dt id="PATCH-constant" class="">PATCH =
|
133
|
-
<div class="docstring">
|
134
|
-
<div class="discussion">
|
135
|
-
|
136
|
-
|
137
|
-
</div>
|
138
|
-
</div>
|
139
|
-
<div class="tags">
|
140
|
-
|
141
|
-
|
142
|
-
</div>
|
143
|
-
</dt>
|
144
|
-
<dd><pre class="code"><span class='int'>2</span></pre></dd>
|
145
|
-
|
146
|
-
<dt id="EDGE-constant" class="">EDGE =
|
147
|
-
<div class="docstring">
|
148
|
-
<div class="discussion">
|
149
|
-
|
150
|
-
|
151
|
-
</div>
|
152
|
-
</div>
|
153
|
-
<div class="tags">
|
154
|
-
|
155
|
-
|
156
|
-
</div>
|
157
|
-
</dt>
|
158
|
-
<dd><pre class="code"><span class='kw'>false</span></pre></dd>
|
159
|
-
|
160
104
|
<dt id="LABEL-constant" class="">LABEL =
|
161
105
|
<div class="docstring">
|
162
106
|
<div class="discussion">
|
@@ -169,7 +113,7 @@
|
|
169
113
|
|
170
114
|
</div>
|
171
115
|
</dt>
|
172
|
-
<dd><pre class="code"><span class='
|
116
|
+
<dd><pre class="code"><span class='lparen'>(</span><span class='const'>Pathname</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='kw'>__FILE__</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span><span class='period'>.</span><span class='id identifier rubyid_dirname'>dirname</span> <span class='op'>/</span> <span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>VERSION</span><span class='tstring_end'>'</span></span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_read'>read</span></pre></dd>
|
173
117
|
|
174
118
|
</dl>
|
175
119
|
|
@@ -185,9 +129,9 @@
|
|
185
129
|
</div>
|
186
130
|
|
187
131
|
<div id="footer">
|
188
|
-
Generated on
|
132
|
+
Generated on Tue Apr 23 17:20:43 2024 by
|
189
133
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
190
|
-
0.9.
|
134
|
+
0.9.36 (ruby-3.2.2).
|
191
135
|
</div>
|
192
136
|
|
193
137
|
</div>
|
data/doc/Anchormodel.html
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
<title>
|
7
7
|
Class: Anchormodel
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.36
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
@@ -116,11 +116,11 @@
|
|
116
116
|
<p class="children">
|
117
117
|
|
118
118
|
|
119
|
-
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Anchormodel/ModelMixin.html" title="Anchormodel::ModelMixin (module)">ModelMixin</a></span>, <span class='object_link'><a href="Anchormodel/Version.html" title="Anchormodel::Version (module)">Version</a></span>
|
119
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Anchormodel/ModelMixin.html" title="Anchormodel::ModelMixin (module)">ModelMixin</a></span>, <span class='object_link'><a href="Anchormodel/Util.html" title="Anchormodel::Util (module)">Util</a></span>, <span class='object_link'><a href="Anchormodel/Version.html" title="Anchormodel::Version (module)">Version</a></span>
|
120
120
|
|
121
121
|
|
122
122
|
|
123
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Anchormodel/
|
123
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html" title="Anchormodel::ActiveModelTypeValueSingle (class)">ActiveModelTypeValueSingle</a></span>, <span class='object_link'><a href="Anchormodel/Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span>
|
124
124
|
|
125
125
|
|
126
126
|
</p>
|
@@ -934,9 +934,9 @@
|
|
934
934
|
</div>
|
935
935
|
|
936
936
|
<div id="footer">
|
937
|
-
Generated on
|
937
|
+
Generated on Tue Apr 23 17:20:43 2024 by
|
938
938
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
939
|
-
0.9.
|
939
|
+
0.9.36 (ruby-3.2.2).
|
940
940
|
</div>
|
941
941
|
|
942
942
|
</div>
|
data/doc/_index.html
CHANGED
@@ -4,7 +4,7 @@
|
|
4
4
|
<meta charset="utf-8">
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
6
6
|
<title>
|
7
|
-
Documentation by YARD 0.9.
|
7
|
+
Documentation by YARD 0.9.36
|
8
8
|
|
9
9
|
</title>
|
10
10
|
|
@@ -52,7 +52,7 @@
|
|
52
52
|
<div class="clear"></div>
|
53
53
|
</div>
|
54
54
|
|
55
|
-
<div id="content"><h1 class="noborder title">Documentation by YARD 0.9.
|
55
|
+
<div id="content"><h1 class="noborder title">Documentation by YARD 0.9.36</h1>
|
56
56
|
<div id="listing">
|
57
57
|
<h1 class="alphaindex">Alphabetic Index</h1>
|
58
58
|
|
@@ -81,7 +81,7 @@
|
|
81
81
|
<ul>
|
82
82
|
|
83
83
|
<li>
|
84
|
-
<span class='object_link'><a href="Anchormodel/
|
84
|
+
<span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html" title="Anchormodel::ActiveModelTypeValueSingle (class)">ActiveModelTypeValueSingle</a></span>
|
85
85
|
|
86
86
|
<small>(Anchormodel)</small>
|
87
87
|
|
@@ -92,6 +92,11 @@
|
|
92
92
|
|
93
93
|
</li>
|
94
94
|
|
95
|
+
<li>
|
96
|
+
<span class='object_link'><a href="AnchormodelGenerator.html" title="AnchormodelGenerator (class)">AnchormodelGenerator</a></span>
|
97
|
+
|
98
|
+
</li>
|
99
|
+
|
95
100
|
<li>
|
96
101
|
<span class='object_link'><a href="Anchormodel/Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span>
|
97
102
|
|
@@ -118,6 +123,21 @@
|
|
118
123
|
</ul>
|
119
124
|
|
120
125
|
|
126
|
+
<ul id="alpha_U" class="alpha">
|
127
|
+
<li class="letter">U</li>
|
128
|
+
<ul>
|
129
|
+
|
130
|
+
<li>
|
131
|
+
<span class='object_link'><a href="Anchormodel/Util.html" title="Anchormodel::Util (module)">Util</a></span>
|
132
|
+
|
133
|
+
<small>(Anchormodel)</small>
|
134
|
+
|
135
|
+
</li>
|
136
|
+
|
137
|
+
</ul>
|
138
|
+
</ul>
|
139
|
+
|
140
|
+
|
121
141
|
<ul id="alpha_V" class="alpha">
|
122
142
|
<li class="letter">V</li>
|
123
143
|
<ul>
|
@@ -141,9 +161,9 @@
|
|
141
161
|
</div>
|
142
162
|
|
143
163
|
<div id="footer">
|
144
|
-
Generated on
|
164
|
+
Generated on Tue Apr 23 17:20:43 2024 by
|
145
165
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
146
|
-
0.9.
|
166
|
+
0.9.36 (ruby-3.2.2).
|
147
167
|
</div>
|
148
168
|
|
149
169
|
</div>
|
data/doc/class_list.html
CHANGED
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
<ul id="full_list" class="class">
|
45
45
|
<li id="object_" class="odd"><div class="item" style="padding-left:30px"><span class='object_link'><a href="top-level-namespace.html" title="Top Level Namespace (root)">Top Level Namespace</a></span></div></li>
|
46
|
-
<li id='object_Anchormodel' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span> < Object<small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Anchormodel::
|
46
|
+
<li id='object_Anchormodel' class='even'><div class='item' style='padding-left:30px'><a class='toggle'></a> <span class='object_link'><a href="Anchormodel.html" title="Anchormodel (class)">Anchormodel</a></span> < Object<small class='search_info'>Top Level Namespace</small></div><ul><li id='object_Anchormodel::ActiveModelTypeValueSingle' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/ActiveModelTypeValueSingle.html" title="Anchormodel::ActiveModelTypeValueSingle (class)">ActiveModelTypeValueSingle</a></span> < Value<small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::Attribute' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/Attribute.html" title="Anchormodel::Attribute (class)">Attribute</a></span> < Object<small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::ModelMixin' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/ModelMixin.html" title="Anchormodel::ModelMixin (module)">ModelMixin</a></span><small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::Util' class='collapsed even'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/Util.html" title="Anchormodel::Util (module)">Util</a></span><small class='search_info'>Anchormodel</small></div></li><li id='object_Anchormodel::Version' class='collapsed odd'><div class='item' style='padding-left:45px'><span class='object_link'><a href="Anchormodel/Version.html" title="Anchormodel::Version (module)">Version</a></span><small class='search_info'>Anchormodel</small></div></li></ul></li><li id='object_AnchormodelGenerator' class='even'><div class='item' style='padding-left:30px'><span class='object_link'><a href="AnchormodelGenerator.html" title="AnchormodelGenerator (class)">AnchormodelGenerator</a></span> < NamedBase<small class='search_info'>Top Level Namespace</small></div></li>
|
47
47
|
|
48
48
|
</ul>
|
49
49
|
</div>
|