compony 0.2.2 → 0.3.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/.gitignore +2 -1
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +3 -3
- data/README.md +80 -13
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/compony.gemspec +5 -5
- data/doc/ComponentGenerator.html +1 -1
- data/doc/Components.html +1 -1
- data/doc/ComponentsGenerator.html +1 -1
- data/doc/Compony/Component.html +308 -341
- data/doc/Compony/ComponentMixins/Default/Labelling.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone/ResourcefulVerbDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone/StandaloneDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone/VerbDsl.html +1 -1
- data/doc/Compony/ComponentMixins/Default/Standalone.html +1 -1
- data/doc/Compony/ComponentMixins/Default.html +1 -1
- data/doc/Compony/ComponentMixins/Resourceful.html +1 -1
- data/doc/Compony/ComponentMixins.html +1 -1
- data/doc/Compony/Components/Button.html +3 -3
- data/doc/Compony/Components/Destroy.html +3 -3
- data/doc/Compony/Components/Edit.html +19 -19
- data/doc/Compony/Components/Form.html +3 -3
- data/doc/Compony/Components/New.html +19 -19
- data/doc/Compony/Components/WithForm.html +4 -4
- data/doc/Compony/Components.html +1 -1
- data/doc/Compony/ControllerMixin.html +1 -1
- data/doc/Compony/Engine.html +1 -1
- data/doc/Compony/MethodAccessibleHash.html +1 -1
- data/doc/Compony/ModelFields/Anchormodel.html +7 -3
- data/doc/Compony/ModelFields/Association.html +1 -1
- data/doc/Compony/ModelFields/Attachment.html +1 -1
- data/doc/Compony/ModelFields/Base.html +1 -1
- data/doc/Compony/ModelFields/Boolean.html +1 -1
- data/doc/Compony/ModelFields/Color.html +1 -1
- data/doc/Compony/ModelFields/Currency.html +1 -1
- data/doc/Compony/ModelFields/Date.html +1 -1
- data/doc/Compony/ModelFields/Datetime.html +1 -1
- data/doc/Compony/ModelFields/Decimal.html +1 -1
- data/doc/Compony/ModelFields/Email.html +1 -1
- data/doc/Compony/ModelFields/Float.html +1 -1
- data/doc/Compony/ModelFields/Integer.html +1 -1
- data/doc/Compony/ModelFields/Percentage.html +1 -1
- data/doc/Compony/ModelFields/Phone.html +1 -1
- data/doc/Compony/ModelFields/RichText.html +1 -1
- data/doc/Compony/ModelFields/String.html +1 -1
- data/doc/Compony/ModelFields/Text.html +1 -1
- data/doc/Compony/ModelFields/Time.html +1 -1
- data/doc/Compony/ModelFields/Url.html +1 -1
- data/doc/Compony/ModelFields.html +1 -1
- data/doc/Compony/ModelMixin.html +1 -1
- data/doc/Compony/NaturalOrdering.html +292 -0
- data/doc/Compony/RequestContext.html +72 -1
- data/doc/Compony/Version.html +1 -1
- data/doc/Compony/ViewHelpers.html +1 -1
- data/doc/Compony.html +3 -3
- data/doc/ComponyController.html +1 -1
- data/doc/_index.html +8 -1
- data/doc/class_list.html +1 -1
- data/doc/file.README.html +73 -16
- data/doc/index.html +73 -16
- data/doc/method_list.html +100 -100
- data/doc/top-level-namespace.html +1 -1
- data/lib/compony/component.rb +30 -54
- data/lib/compony/components/edit.rb +2 -4
- data/lib/compony/components/new.rb +4 -6
- data/lib/compony/components/with_form.rb +1 -1
- data/lib/compony/model_fields/anchormodel.rb +3 -1
- data/lib/compony/natural_ordering.rb +56 -0
- data/lib/compony/request_context.rb +8 -0
- data/lib/compony.rb +1 -0
- metadata +6 -4
|
@@ -311,7 +311,9 @@
|
|
|
311
311
|
17
|
|
312
312
|
18
|
|
313
313
|
19
|
|
314
|
-
20
|
|
314
|
+
20
|
|
315
|
+
21
|
|
316
|
+
22</pre>
|
|
315
317
|
</td>
|
|
316
318
|
<td>
|
|
317
319
|
<pre class="code"><span class="info file"># File 'lib/compony/model_fields/anchormodel.rb', line 13</span>
|
|
@@ -319,8 +321,10 @@
|
|
|
319
321
|
<span class='kw'>def</span> <span class='id identifier rubyid_simpleform_input_hidden'>simpleform_input_hidden</span><span class='lparen'>(</span><span class='id identifier rubyid_form'>form</span><span class='comma'>,</span> <span class='id identifier rubyid__component'>_component</span><span class='comma'>,</span> <span class='label'>name:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_input_opts'>input_opts</span><span class='rparen'>)</span>
|
|
320
322
|
<span class='kw'>if</span> <span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span>
|
|
321
323
|
<span class='id identifier rubyid_selected_cst'>selected_cst</span> <span class='op'>=</span> <span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_send'>send</span><span class='lparen'>(</span><span class='ivar'>@name</span><span class='rparen'>)</span>
|
|
324
|
+
<span class='id identifier rubyid_am_attr'>am_attr</span> <span class='op'>=</span> <span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_object'>object</span><span class='period'>.</span><span class='id identifier rubyid_class'>class</span><span class='period'>.</span><span class='id identifier rubyid_anchormodel_attributes'>anchormodel_attributes</span><span class='lbracket'>[</span><span class='ivar'>@name</span><span class='rbracket'>]</span>
|
|
325
|
+
<span class='id identifier rubyid_am_serializer'>am_serializer</span> <span class='op'>=</span> <span class='lparen'>(</span><span class='id identifier rubyid_am_attr'>am_attr</span><span class='period'>.</span><span class='id identifier rubyid_multiple?'>multiple?</span> <span class='op'>?</span> <span class='op'>::</span><span class='const'>Anchormodel</span><span class='op'>::</span><span class='const'>ActiveModelTypeValueMulti</span> <span class='op'>:</span> <span class='op'>::</span><span class='const'>Anchormodel</span><span class='op'>::</span><span class='const'>ActiveModelTypeValueSingle</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='id identifier rubyid_am_attr'>am_attr</span><span class='rparen'>)</span>
|
|
322
326
|
<span class='id identifier rubyid_input_opts'>input_opts</span><span class='lbracket'>[</span><span class='symbol'>:input_html</span><span class='rbracket'>]</span> <span class='op'>||=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
|
323
|
-
<span class='id identifier rubyid_input_opts'>input_opts</span><span class='lbracket'>[</span><span class='symbol'>:input_html</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier
|
|
327
|
+
<span class='id identifier rubyid_input_opts'>input_opts</span><span class='lbracket'>[</span><span class='symbol'>:input_html</span><span class='rbracket'>]</span><span class='lbracket'>[</span><span class='symbol'>:value</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_am_serializer'>am_serializer</span><span class='period'>.</span><span class='id identifier rubyid_serialize'>serialize</span><span class='lparen'>(</span><span class='id identifier rubyid_selected_cst'>selected_cst</span><span class='rparen'>)</span>
|
|
324
328
|
<span class='kw'>end</span>
|
|
325
329
|
<span class='kw'>return</span> <span class='id identifier rubyid_form'>form</span><span class='period'>.</span><span class='id identifier rubyid_input'>input</span> <span class='id identifier rubyid_name'>name</span> <span class='op'>||</span> <span class='ivar'>@name</span><span class='comma'>,</span> <span class='label'>as:</span> <span class='symbol'>:hidden</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_input_opts'>input_opts</span>
|
|
326
330
|
<span class='kw'>end</span></pre>
|
|
@@ -373,7 +377,7 @@
|
|
|
373
377
|
</div>
|
|
374
378
|
|
|
375
379
|
<div id="footer">
|
|
376
|
-
Generated on Wed
|
|
380
|
+
Generated on Wed May 29 15:53:01 2024 by
|
|
377
381
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
378
382
|
0.9.34 (ruby-3.2.2).
|
|
379
383
|
</div>
|
|
@@ -603,7 +603,7 @@
|
|
|
603
603
|
</div>
|
|
604
604
|
|
|
605
605
|
<div id="footer">
|
|
606
|
-
Generated on Wed
|
|
606
|
+
Generated on Wed May 29 15:53:01 2024 by
|
|
607
607
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
608
608
|
0.9.34 (ruby-3.2.2).
|
|
609
609
|
</div>
|
|
@@ -295,7 +295,7 @@
|
|
|
295
295
|
</div>
|
|
296
296
|
|
|
297
297
|
<div id="footer">
|
|
298
|
-
Generated on Wed
|
|
298
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
299
299
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
300
300
|
0.9.34 (ruby-3.2.2).
|
|
301
301
|
</div>
|
|
@@ -1056,7 +1056,7 @@
|
|
|
1056
1056
|
</div>
|
|
1057
1057
|
|
|
1058
1058
|
<div id="footer">
|
|
1059
|
-
Generated on Wed
|
|
1059
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
1060
1060
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
1061
1061
|
0.9.34 (ruby-3.2.2).
|
|
1062
1062
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Wed
|
|
225
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.2.2).
|
|
228
228
|
</div>
|
|
@@ -289,7 +289,7 @@
|
|
|
289
289
|
</div>
|
|
290
290
|
|
|
291
291
|
<div id="footer">
|
|
292
|
-
Generated on Wed
|
|
292
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
293
293
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
294
294
|
0.9.34 (ruby-3.2.2).
|
|
295
295
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Wed
|
|
225
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.2.2).
|
|
228
228
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Wed
|
|
225
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.2.2).
|
|
228
228
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Wed
|
|
225
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.2.2).
|
|
228
228
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Wed
|
|
147
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.2.2).
|
|
150
150
|
</div>
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
</div>
|
|
231
231
|
|
|
232
232
|
<div id="footer">
|
|
233
|
-
Generated on Wed
|
|
233
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
234
234
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
235
235
|
0.9.34 (ruby-3.2.2).
|
|
236
236
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Wed
|
|
147
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.2.2).
|
|
150
150
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Wed
|
|
147
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.2.2).
|
|
150
150
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Wed
|
|
225
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.2.2).
|
|
228
228
|
</div>
|
|
@@ -291,7 +291,7 @@
|
|
|
291
291
|
</div>
|
|
292
292
|
|
|
293
293
|
<div id="footer">
|
|
294
|
-
Generated on Wed
|
|
294
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
295
295
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
296
296
|
0.9.34 (ruby-3.2.2).
|
|
297
297
|
</div>
|
|
@@ -222,7 +222,7 @@
|
|
|
222
222
|
</div>
|
|
223
223
|
|
|
224
224
|
<div id="footer">
|
|
225
|
-
Generated on Wed
|
|
225
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
226
226
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
227
227
|
0.9.34 (ruby-3.2.2).
|
|
228
228
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Wed
|
|
147
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.2.2).
|
|
150
150
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Wed
|
|
147
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.2.2).
|
|
150
150
|
</div>
|
|
@@ -144,7 +144,7 @@
|
|
|
144
144
|
</div>
|
|
145
145
|
|
|
146
146
|
<div id="footer">
|
|
147
|
-
Generated on Wed
|
|
147
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
148
148
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
149
149
|
0.9.34 (ruby-3.2.2).
|
|
150
150
|
</div>
|
|
@@ -230,7 +230,7 @@
|
|
|
230
230
|
</div>
|
|
231
231
|
|
|
232
232
|
<div id="footer">
|
|
233
|
-
Generated on Wed
|
|
233
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
234
234
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
235
235
|
0.9.34 (ruby-3.2.2).
|
|
236
236
|
</div>
|
|
@@ -116,7 +116,7 @@
|
|
|
116
116
|
</div>
|
|
117
117
|
|
|
118
118
|
<div id="footer">
|
|
119
|
-
Generated on Wed
|
|
119
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
120
120
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
121
121
|
0.9.34 (ruby-3.2.2).
|
|
122
122
|
</div>
|
data/doc/Compony/ModelMixin.html
CHANGED
|
@@ -514,7 +514,7 @@
|
|
|
514
514
|
</div>
|
|
515
515
|
|
|
516
516
|
<div id="footer">
|
|
517
|
-
Generated on Wed
|
|
517
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
518
518
|
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
519
519
|
0.9.34 (ruby-3.2.2).
|
|
520
520
|
</div>
|
|
@@ -0,0 +1,292 @@
|
|
|
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: Compony::NaturalOrdering
|
|
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 = "Compony::NaturalOrdering";
|
|
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 (N)</a> »
|
|
40
|
+
<span class='title'><span class='object_link'><a href="../Compony.html" title="Compony (module)">Compony</a></span></span>
|
|
41
|
+
»
|
|
42
|
+
<span class="title">NaturalOrdering</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: Compony::NaturalOrdering
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
|
|
66
|
+
</h1>
|
|
67
|
+
<div class="box_info">
|
|
68
|
+
|
|
69
|
+
<dl>
|
|
70
|
+
<dt>Inherits:</dt>
|
|
71
|
+
<dd>
|
|
72
|
+
<span class="inheritName">Array</span>
|
|
73
|
+
|
|
74
|
+
<ul class="fullTree">
|
|
75
|
+
<li>Object</li>
|
|
76
|
+
|
|
77
|
+
<li class="next">Array</li>
|
|
78
|
+
|
|
79
|
+
<li class="next">Compony::NaturalOrdering</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/compony/natural_ordering.rb</dd>
|
|
100
|
+
</dl>
|
|
101
|
+
|
|
102
|
+
</div>
|
|
103
|
+
|
|
104
|
+
<h2>Overview</h2><div class="docstring">
|
|
105
|
+
<div class="discussion">
|
|
106
|
+
|
|
107
|
+
<p>This class provides an array-based data structure where elements have symbol names. New elements can be appended or placed at a location using <code>before:</code>. Important: do not mutate this class with any other method call than the natural_-prefixed methods defined below. Example:<br></p>
|
|
108
|
+
|
|
109
|
+
<pre class="code ruby"><code class="ruby"><span class='id identifier rubyid_collection'>collection</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="../Compony.html" title="Compony (module)">Compony</a></span></span><span class='op'>::</span><span class='const'>NaturalOrdering</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span>
|
|
110
|
+
<span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:a</span><span class='comma'>,</span> <span class='id identifier rubyid_a_payload'>a_payload</span><span class='rparen'>)</span>
|
|
111
|
+
<span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:c</span><span class='comma'>,</span> <span class='id identifier rubyid_c_payload'>c_payload</span><span class='rparen'>)</span>
|
|
112
|
+
<span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:b</span><span class='comma'>,</span> <span class='id identifier rubyid_b_payload'>b_payload</span><span class='comma'>,</span> <span class='label'>before:</span> <span class='symbol'>:c</span><span class='rparen'>)</span>
|
|
113
|
+
<span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:d</span><span class='comma'>,</span> <span class='id identifier rubyid_d_payload'>d_payload</span><span class='comma'>,</span> <span class='label'>hidden:</span> <span class='kw'>true</span><span class='rparen'>)</span>
|
|
114
|
+
<span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='symbol'>:a</span><span class='comma'>,</span> <span class='id identifier rubyid_a_new_payload'>a_new_payload</span><span class='rparen'>)</span> <span class='comment'># overwrites :a
|
|
115
|
+
</span>
|
|
116
|
+
<span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_reject'>reject</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_hidden'>hidden</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:name</span><span class='rparen'>)</span> <span class='comment'># --> :a, :b, :c
|
|
117
|
+
</span><span class='id identifier rubyid_collection'>collection</span><span class='period'>.</span><span class='id identifier rubyid_map'>map</span><span class='lparen'>(</span><span class='op'>&</span><span class='symbol'>:payload</span><span class='rparen'>)</span> <span class='comment'># --> a_new_payload, b_payload, c_payload, d_payload
|
|
118
|
+
</span></code></pre>
|
|
119
|
+
|
|
120
|
+
|
|
121
|
+
</div>
|
|
122
|
+
</div>
|
|
123
|
+
<div class="tags">
|
|
124
|
+
|
|
125
|
+
|
|
126
|
+
</div>
|
|
127
|
+
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
|
|
131
|
+
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
<h2>
|
|
135
|
+
Instance Method Summary
|
|
136
|
+
<small><a href="#" class="summary_toggle">collapse</a></small>
|
|
137
|
+
</h2>
|
|
138
|
+
|
|
139
|
+
<ul class="summary">
|
|
140
|
+
|
|
141
|
+
<li class="public ">
|
|
142
|
+
<span class="summary_signature">
|
|
143
|
+
|
|
144
|
+
<a href="#natural_push-instance_method" title="#natural_push (instance method)">#<strong>natural_push</strong>(name, payload, before: nil, **kwargs) ⇒ Object </a>
|
|
145
|
+
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
</span>
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
|
|
156
|
+
|
|
157
|
+
|
|
158
|
+
<span class="summary_desc"><div class='inline'></div></span>
|
|
159
|
+
|
|
160
|
+
</li>
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
</ul>
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
<div id="instance_method_details" class="method_details_list">
|
|
170
|
+
<h2>Instance Method Details</h2>
|
|
171
|
+
|
|
172
|
+
|
|
173
|
+
<div class="method_details first">
|
|
174
|
+
<h3 class="signature first" id="natural_push-instance_method">
|
|
175
|
+
|
|
176
|
+
#<strong>natural_push</strong>(name, payload, before: nil, **kwargs) ⇒ <tt>Object</tt>
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
</h3><div class="docstring">
|
|
183
|
+
<div class="discussion">
|
|
184
|
+
|
|
185
|
+
|
|
186
|
+
</div>
|
|
187
|
+
</div>
|
|
188
|
+
<div class="tags">
|
|
189
|
+
|
|
190
|
+
|
|
191
|
+
</div><table class="source_code">
|
|
192
|
+
<tr>
|
|
193
|
+
<td>
|
|
194
|
+
<pre class="lines">
|
|
195
|
+
|
|
196
|
+
|
|
197
|
+
18
|
|
198
|
+
19
|
|
199
|
+
20
|
|
200
|
+
21
|
|
201
|
+
22
|
|
202
|
+
23
|
|
203
|
+
24
|
|
204
|
+
25
|
|
205
|
+
26
|
|
206
|
+
27
|
|
207
|
+
28
|
|
208
|
+
29
|
|
209
|
+
30
|
|
210
|
+
31
|
|
211
|
+
32
|
|
212
|
+
33
|
|
213
|
+
34
|
|
214
|
+
35
|
|
215
|
+
36
|
|
216
|
+
37
|
|
217
|
+
38
|
|
218
|
+
39
|
|
219
|
+
40
|
|
220
|
+
41
|
|
221
|
+
42
|
|
222
|
+
43
|
|
223
|
+
44
|
|
224
|
+
45
|
|
225
|
+
46
|
|
226
|
+
47
|
|
227
|
+
48
|
|
228
|
+
49
|
|
229
|
+
50
|
|
230
|
+
51
|
|
231
|
+
52
|
|
232
|
+
53
|
|
233
|
+
54</pre>
|
|
234
|
+
</td>
|
|
235
|
+
<td>
|
|
236
|
+
<pre class="code"><span class="info file"># File 'lib/compony/natural_ordering.rb', line 18</span>
|
|
237
|
+
|
|
238
|
+
<span class='kw'>def</span> <span class='id identifier rubyid_natural_push'>natural_push</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='comma'>,</span> <span class='id identifier rubyid_payload'>payload</span><span class='comma'>,</span> <span class='label'>before:</span> <span class='kw'>nil</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span>
|
|
239
|
+
<span class='id identifier rubyid_name'>name</span> <span class='op'>=</span> <span class='id identifier rubyid_name'>name</span><span class='period'>.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
|
|
240
|
+
<span class='id identifier rubyid_before_name'>before_name</span> <span class='op'>=</span> <span class='id identifier rubyid_before'>before</span><span class='op'>&.</span><span class='id identifier rubyid_to_sym'>to_sym</span>
|
|
241
|
+
<span class='id identifier rubyid_old_kwargs'>old_kwargs</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='rbrace'>}</span>
|
|
242
|
+
|
|
243
|
+
<span class='comment'># Fetch existing element if any
|
|
244
|
+
</span> <span class='id identifier rubyid_existing_index'>existing_index</span> <span class='op'>=</span> <span class='id identifier rubyid_find_index'>find_index</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='id identifier rubyid_name'>name</span> <span class='rbrace'>}</span>
|
|
245
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_existing_index'>existing_index</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
|
246
|
+
<span class='comment'># Copy all non-mentionned kwargs from the element we are about to overwrite
|
|
247
|
+
</span> <span class='id identifier rubyid_old_kwargs'>old_kwargs</span> <span class='op'>=</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_existing_index'>existing_index</span><span class='rbracket'>]</span><span class='period'>.</span><span class='id identifier rubyid_except'>except</span><span class='lparen'>(</span><span class='symbol'>:name</span><span class='comma'>,</span> <span class='symbol'>:payload</span><span class='rparen'>)</span>
|
|
248
|
+
|
|
249
|
+
<span class='comment'># Replacing an existing element with a before: directive - must delete before calculating indices
|
|
250
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_before_name'>before_name</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
|
251
|
+
<span class='id identifier rubyid_delete_at'>delete_at</span><span class='lparen'>(</span><span class='id identifier rubyid_existing_index'>existing_index</span><span class='rparen'>)</span>
|
|
252
|
+
<span class='kw'>end</span>
|
|
253
|
+
<span class='kw'>end</span>
|
|
254
|
+
|
|
255
|
+
<span class='comment'># Fetch before element
|
|
256
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_before_name'>before_name</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
|
257
|
+
<span class='id identifier rubyid_before_index'>before_index</span> <span class='op'>=</span> <span class='id identifier rubyid_find_index'>find_index</span> <span class='lbrace'>{</span> <span class='op'>|</span><span class='id identifier rubyid_el'>el</span><span class='op'>|</span> <span class='id identifier rubyid_el'>el</span><span class='period'>.</span><span class='id identifier rubyid_name'>name</span> <span class='op'>==</span> <span class='id identifier rubyid_before_name'>before_name</span> <span class='rbrace'>}</span> <span class='op'>||</span> <span class='id identifier rubyid_fail'>fail</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Element </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_before_name'>before_name</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='embexpr_end'>}</span><span class='tstring_content'> for :before not found in </span><span class='embexpr_beg'>#{</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>
|
|
258
|
+
<span class='kw'>end</span>
|
|
259
|
+
|
|
260
|
+
<span class='comment'># Create the element to insert
|
|
261
|
+
</span> <span class='id identifier rubyid_element'>element</span> <span class='op'>=</span> <span class='const'><span class='object_link'><a href="MethodAccessibleHash.html" title="Compony::MethodAccessibleHash (class)">MethodAccessibleHash</a></span></span><span class='period'>.</span><span class='id identifier rubyid_new'><span class='object_link'><a href="MethodAccessibleHash.html#initialize-instance_method" title="Compony::MethodAccessibleHash#initialize (method)">new</a></span></span><span class='lparen'>(</span><span class='label'>name:</span><span class='comma'>,</span> <span class='label'>payload:</span><span class='comma'>,</span> <span class='op'>**</span><span class='id identifier rubyid_old_kwargs'>old_kwargs</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_kwargs'>kwargs</span><span class='rparen'>)</span><span class='rparen'>)</span>
|
|
262
|
+
|
|
263
|
+
<span class='comment'># Insert new element
|
|
264
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_before_index'>before_index</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
|
265
|
+
<span class='comment'># Insert before another element
|
|
266
|
+
</span> <span class='id identifier rubyid_insert'>insert</span><span class='lparen'>(</span><span class='id identifier rubyid_before_index'>before_index</span><span class='comma'>,</span> <span class='id identifier rubyid_element'>element</span><span class='rparen'>)</span>
|
|
267
|
+
<span class='kw'>elsif</span> <span class='id identifier rubyid_existing_index'>existing_index</span><span class='period'>.</span><span class='id identifier rubyid_present?'>present?</span>
|
|
268
|
+
<span class='comment'># Override another element
|
|
269
|
+
</span> <span class='kw'>self</span><span class='lbracket'>[</span><span class='id identifier rubyid_existing_index'>existing_index</span><span class='rbracket'>]</span> <span class='op'>=</span> <span class='id identifier rubyid_element'>element</span>
|
|
270
|
+
<span class='kw'>else</span>
|
|
271
|
+
<span class='comment'># Append at the end
|
|
272
|
+
</span> <span class='kw'>self</span> <span class='op'><<</span> <span class='id identifier rubyid_element'>element</span>
|
|
273
|
+
<span class='kw'>end</span>
|
|
274
|
+
<span class='kw'>end</span></pre>
|
|
275
|
+
</td>
|
|
276
|
+
</tr>
|
|
277
|
+
</table>
|
|
278
|
+
</div>
|
|
279
|
+
|
|
280
|
+
</div>
|
|
281
|
+
|
|
282
|
+
</div>
|
|
283
|
+
|
|
284
|
+
<div id="footer">
|
|
285
|
+
Generated on Wed May 29 15:53:00 2024 by
|
|
286
|
+
<a href="https://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
|
287
|
+
0.9.34 (ruby-3.2.2).
|
|
288
|
+
</div>
|
|
289
|
+
|
|
290
|
+
</div>
|
|
291
|
+
</body>
|
|
292
|
+
</html>
|