ovto 0.6.0.rc1 → 0.6.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/CHANGELOG.md +2 -2
- data/Gemfile.lock +1 -1
- data/book/SUMMARY.md +1 -0
- data/book/api/actions.md +1 -1
- data/book/api/middleware.md +93 -0
- data/docs/api/Ovto.html +222 -25
- data/docs/api/Ovto/Actions.html +132 -40
- data/docs/api/Ovto/App.html +254 -40
- data/docs/api/Ovto/Component.html +96 -29
- data/docs/api/Ovto/Component/MoreThanOneNode.html +6 -6
- data/docs/api/Ovto/PureComponent.html +11 -11
- data/docs/api/Ovto/PureComponent/StateIsNotAvailable.html +6 -6
- data/docs/api/Ovto/Runtime.html +7 -7
- data/docs/api/Ovto/State.html +58 -42
- data/docs/api/Ovto/State/MissingValue.html +6 -6
- data/docs/api/Ovto/WiredActions.html +78 -35
- data/docs/api/_index.html +54 -11
- data/docs/api/actions.html +1 -1
- data/docs/api/app.html +1 -1
- data/docs/api/class_list.html +3 -3
- data/docs/api/component.html +1 -1
- data/docs/api/css/style.css +2 -2
- data/docs/api/fetch.html +1 -1
- data/docs/api/file.README.html +6 -6
- data/docs/api/file_list.html +2 -2
- data/docs/api/frames.html +2 -2
- data/docs/api/index.html +6 -6
- data/docs/api/js/app.js +14 -3
- data/docs/api/method_list.html +270 -30
- data/docs/api/pure_component.html +1 -1
- data/docs/api/state.html +1 -1
- data/docs/api/top-level-namespace.html +6 -6
- data/docs/guides/debugging.html +1 -1
- data/docs/guides/development.html +1 -1
- data/docs/guides/install.html +1 -1
- data/docs/guides/tutorial.html +1 -1
- data/docs/index.html +1 -1
- data/examples/static/Gemfile.lock +1 -1
- data/lib/ovto/version.rb +1 -1
- metadata +5 -5
- data/docs/api/Ovto/State/UnknownKey.html +0 -135
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d4dfe5798db6f31627dccb56a9d88dfbd80137f1190f5dae9a4adac0ce04d4af
|
4
|
+
data.tar.gz: 96c3ca007adddbfe5c81ac0f53e0ac3bcca78c8d246480b4f15474d0fd6e066f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e6e7adbef82402b2ddb96387a502d0382aa9dff8d184fc25276f9a5b4911ff54a6b4d9bde853c123deef378cdee508fe1a0a9d15590e0aeafb399c870d340a3
|
7
|
+
data.tar.gz: 3fe2f79ba887239d36fcfa03a88d65594db4d8c3e9ad4819a63bd63b5b3570f14611c56b05d5d51587d0dfe844f0d1f82d1775c916060c4b2e1442b7920cbaf9
|
data/CHANGELOG.md
CHANGED
@@ -1,6 +1,7 @@
|
|
1
|
-
##
|
1
|
+
## v0.6.0 (2020-02-29)
|
2
2
|
|
3
3
|
- feat: Ovto::Middleware (#18)
|
4
|
+
- Experimental. API may change during 0.6.x
|
4
5
|
- feat(State): default_proc (#17)
|
5
6
|
- feat(o): `o SubComp do ...end` now passes the block to `SubComp#render` (#16)
|
6
7
|
|
@@ -24,7 +25,6 @@ New features
|
|
24
25
|
Example:
|
25
26
|
|
26
27
|
o 'div', `{nodeName: ....}`
|
27
|
-
|
28
28
|
|
29
29
|
## v0.3.0 (2018-12-24)
|
30
30
|
|
data/Gemfile.lock
CHANGED
data/book/SUMMARY.md
CHANGED
data/book/api/actions.md
CHANGED
@@ -0,0 +1,93 @@
|
|
1
|
+
# Ovto::Middleware
|
2
|
+
|
3
|
+
When you are making a big app with Ovto, you may want to extract
|
4
|
+
certain parts which are independent from the app. Ovto::Middleware is
|
5
|
+
for such cases.
|
6
|
+
|
7
|
+
- A middleware has its own namespace of state and actions
|
8
|
+
- that is, you don't need to add prefixes to the names of states and actions of a middleware.
|
9
|
+
|
10
|
+
## Example
|
11
|
+
|
12
|
+
```rb
|
13
|
+
# 1. Middleware name must be valid as a method name in Ruby
|
14
|
+
class MyMiddleware < Ovto::Middleware("my_middleware")
|
15
|
+
def setup
|
16
|
+
# Called on app startup
|
17
|
+
end
|
18
|
+
|
19
|
+
# 2. Make a subclass of MyMiddleware's State
|
20
|
+
class State < MyMiddleware::State
|
21
|
+
item :count, default: 0
|
22
|
+
end
|
23
|
+
|
24
|
+
# 3. Make a subclass of MyMiddleware's Actions
|
25
|
+
class Actions < MyMiddleware::Actions
|
26
|
+
def increment(by:)
|
27
|
+
return {count: state.count + by}
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# 4. Make a subclass of MyMiddleware's Component
|
32
|
+
class SomeComponent < MyMiddleware::Component
|
33
|
+
def render
|
34
|
+
o 'span', state.count
|
35
|
+
o 'button', onclick: ->{ actions.increment(by: 1) }
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class MyApp < Ovto::App
|
41
|
+
# 5. Declare middlewares to use
|
42
|
+
use MyMiddleware
|
43
|
+
|
44
|
+
class State < Ovto::State; end
|
45
|
+
class Actions < Ovto::Actions; end
|
46
|
+
|
47
|
+
class MainComponent < Ovto::Component
|
48
|
+
def render
|
49
|
+
o 'div.counter' do
|
50
|
+
o MyMiddleware::SomeComponent
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
```
|
55
|
+
|
56
|
+
## Advanced
|
57
|
+
|
58
|
+
### Getting middlware state from app
|
59
|
+
|
60
|
+
```rb
|
61
|
+
class MyApp < Ovto::App
|
62
|
+
def MainComponent < Ovto::Component
|
63
|
+
def render
|
64
|
+
o 'span', state._middlewares.middleware1.some_state
|
65
|
+
end
|
66
|
+
end
|
67
|
+
```
|
68
|
+
|
69
|
+
### Calling middlware action from app
|
70
|
+
|
71
|
+
```rb
|
72
|
+
class MyApp < Ovto::App
|
73
|
+
# From actions
|
74
|
+
def Actions < Ovto::Actions
|
75
|
+
def some_action
|
76
|
+
actions.middleware1.some_action()
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# From component
|
81
|
+
def MainComponent < Ovto::Component
|
82
|
+
def render
|
83
|
+
o 'button', onclick: ->{ actions.middleware1.some_action() }
|
84
|
+
end
|
85
|
+
end
|
86
|
+
```
|
87
|
+
|
88
|
+
### Using a middleware from another middleware
|
89
|
+
|
90
|
+
```rb
|
91
|
+
class Middleware1 < Ovto::Middleware("middleware1")
|
92
|
+
use Middleware2
|
93
|
+
```
|
data/docs/api/Ovto.html
CHANGED
@@ -6,15 +6,15 @@
|
|
6
6
|
<title>
|
7
7
|
Module: Ovto
|
8
8
|
|
9
|
-
— Documentation by YARD 0.9.
|
9
|
+
— Documentation by YARD 0.9.24
|
10
10
|
|
11
11
|
</title>
|
12
12
|
|
13
|
-
<link rel="stylesheet" href="css/style.css" type="text/css"
|
13
|
+
<link rel="stylesheet" href="css/style.css" type="text/css" />
|
14
14
|
|
15
|
-
<link rel="stylesheet" href="css/common.css" type="text/css"
|
15
|
+
<link rel="stylesheet" href="css/common.css" type="text/css" />
|
16
16
|
|
17
|
-
<script type="text/javascript"
|
17
|
+
<script type="text/javascript">
|
18
18
|
pathId = "Ovto";
|
19
19
|
relpath = '';
|
20
20
|
</script>
|
@@ -79,7 +79,7 @@
|
|
79
79
|
<dl>
|
80
80
|
<dt>Defined in:</dt>
|
81
81
|
<dd>lib/ovto.rb<span class="defines">,<br />
|
82
|
-
lib/ovto/app.rb,<br /> lib/ovto/fetch.rb,<br /> lib/ovto/state.rb,<br /> lib/ovto/actions.rb,<br /> lib/ovto/runtime.rb,<br /> lib/ovto/version.rb,<br /> lib/ovto/component.rb,<br /> lib/ovto/wired_actions.rb,<br /> lib/ovto/pure_component.rb</span>
|
82
|
+
lib/ovto/app.rb,<br /> lib/ovto/fetch.rb,<br /> lib/ovto/state.rb,<br /> lib/ovto/actions.rb,<br /> lib/ovto/runtime.rb,<br /> lib/ovto/version.rb,<br /> lib/ovto/component.rb,<br /> lib/ovto/middleware.rb,<br /> lib/ovto/wired_actions.rb,<br /> lib/ovto/pure_component.rb,<br /> lib/ovto/wired_action_set.rb</span>
|
83
83
|
</dd>
|
84
84
|
</dl>
|
85
85
|
|
@@ -89,9 +89,11 @@
|
|
89
89
|
<p class="children">
|
90
90
|
|
91
91
|
|
92
|
+
<strong class="modules">Modules:</strong> <span class='object_link'><a href="Ovto/Middleware.html" title="Ovto::Middleware (module)">Middleware</a></span>
|
93
|
+
|
92
94
|
|
93
95
|
|
94
|
-
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Ovto/Actions.html" title="Ovto::Actions (class)">Actions</a></span>, <span class='object_link'><a href="Ovto/App.html" title="Ovto::App (class)">App</a></span>, <span class='object_link'><a href="Ovto/Component.html" title="Ovto::Component (class)">Component</a></span>, <span class='object_link'><a href="Ovto/PureComponent.html" title="Ovto::PureComponent (class)">PureComponent</a></span>, <span class='object_link'><a href="Ovto/Runtime.html" title="Ovto::Runtime (class)">Runtime</a></span>, <span class='object_link'><a href="Ovto/State.html" title="Ovto::State (class)">State</a></span>, <span class='object_link'><a href="Ovto/WiredActions.html" title="Ovto::WiredActions (class)">WiredActions</a></span>
|
96
|
+
<strong class="classes">Classes:</strong> <span class='object_link'><a href="Ovto/Actions.html" title="Ovto::Actions (class)">Actions</a></span>, <span class='object_link'><a href="Ovto/App.html" title="Ovto::App (class)">App</a></span>, <span class='object_link'><a href="Ovto/Component.html" title="Ovto::Component (class)">Component</a></span>, <span class='object_link'><a href="Ovto/PureComponent.html" title="Ovto::PureComponent (class)">PureComponent</a></span>, <span class='object_link'><a href="Ovto/Runtime.html" title="Ovto::Runtime (class)">Runtime</a></span>, <span class='object_link'><a href="Ovto/State.html" title="Ovto::State (class)">State</a></span>, <span class='object_link'><a href="Ovto/WiredActionSet.html" title="Ovto::WiredActionSet (class)">WiredActionSet</a></span>, <span class='object_link'><a href="Ovto/WiredActions.html" title="Ovto::WiredActions (class)">WiredActions</a></span>
|
95
97
|
|
96
98
|
|
97
99
|
</p>
|
@@ -107,7 +109,12 @@
|
|
107
109
|
<dt id="VERSION-constant" class="">VERSION =
|
108
110
|
|
109
111
|
</dt>
|
110
|
-
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0.
|
112
|
+
<dd><pre class="code"><span class='tstring'><span class='tstring_beg'>'</span><span class='tstring_content'>0.6.0.rc1</span><span class='tstring_end'>'</span></span></pre></dd>
|
113
|
+
|
114
|
+
<dt id="VALID_NAME_REXP-constant" class="">VALID_NAME_REXP =
|
115
|
+
|
116
|
+
</dt>
|
117
|
+
<dd><pre class="code"><span class='tstring'><span class='regexp_beg'>/</span><span class='tstring_content'>\A[a-zA-Z0-9_]+\z</span><span class='regexp_end'>/</span></span></pre></dd>
|
111
118
|
|
112
119
|
</dl>
|
113
120
|
|
@@ -285,6 +292,56 @@
|
|
285
292
|
<p>Call block.</p>
|
286
293
|
</div></span>
|
287
294
|
|
295
|
+
</li>
|
296
|
+
|
297
|
+
|
298
|
+
<li class="public ">
|
299
|
+
<span class="summary_signature">
|
300
|
+
|
301
|
+
<a href="#Middleware-class_method" title="Middleware (class method)">.<strong>Middleware</strong>(name) ⇒ Object </a>
|
302
|
+
|
303
|
+
|
304
|
+
|
305
|
+
</span>
|
306
|
+
|
307
|
+
|
308
|
+
|
309
|
+
|
310
|
+
|
311
|
+
|
312
|
+
|
313
|
+
|
314
|
+
|
315
|
+
<span class="summary_desc"><div class='inline'>
|
316
|
+
<p>Create an ancestor of middleware class Example: class MiddlewareExample
|
317
|
+
< Ovto::Middleware(“middleware_example”).</p>
|
318
|
+
</div></span>
|
319
|
+
|
320
|
+
</li>
|
321
|
+
|
322
|
+
|
323
|
+
<li class="public ">
|
324
|
+
<span class="summary_signature">
|
325
|
+
|
326
|
+
<a href="#send_args_with_state-class_method" title="send_args_with_state (class method)">.<strong>send_args_with_state</strong>(obj, meth, args, state, &block) ⇒ Object </a>
|
327
|
+
|
328
|
+
|
329
|
+
|
330
|
+
</span>
|
331
|
+
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
|
340
|
+
<span class="summary_desc"><div class='inline'>
|
341
|
+
<p>Something like `obj.meth(state: state, **args, &block)` Safe even if
|
342
|
+
`obj.meth` does not have `state:`.</p>
|
343
|
+
</div></span>
|
344
|
+
|
288
345
|
</li>
|
289
346
|
|
290
347
|
|
@@ -385,10 +442,10 @@
|
|
385
442
|
<pre class="lines">
|
386
443
|
|
387
444
|
|
388
|
-
|
445
|
+
22</pre>
|
389
446
|
</td>
|
390
447
|
<td>
|
391
|
-
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line
|
448
|
+
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line 22</span>
|
392
449
|
|
393
450
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_debug_trace'>debug_trace</span><span class='semicolon'>;</span> <span class='ivar'>@debug_trace</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
|
394
451
|
</td>
|
@@ -411,10 +468,10 @@
|
|
411
468
|
<pre class="lines">
|
412
469
|
|
413
470
|
|
414
|
-
|
471
|
+
23</pre>
|
415
472
|
</td>
|
416
473
|
<td>
|
417
|
-
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line
|
474
|
+
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line 23</span>
|
418
475
|
|
419
476
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_debug_trace='>debug_trace=</span><span class='lparen'>(</span><span class='id identifier rubyid_bool'>bool</span><span class='rparen'>)</span><span class='semicolon'>;</span> <span class='ivar'>@debug_trace</span> <span class='op'>=</span> <span class='id identifier rubyid_bool'>bool</span><span class='semicolon'>;</span> <span class='kw'>end</span></pre>
|
420
477
|
</td>
|
@@ -437,12 +494,12 @@
|
|
437
494
|
<pre class="lines">
|
438
495
|
|
439
496
|
|
440
|
-
|
441
|
-
|
442
|
-
|
497
|
+
24
|
498
|
+
25
|
499
|
+
26</pre>
|
443
500
|
</td>
|
444
501
|
<td>
|
445
|
-
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line
|
502
|
+
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line 24</span>
|
446
503
|
|
447
504
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_debug_trace_log'>debug_trace_log</span><span class='lparen'>(</span><span class='id identifier rubyid_msg'>msg</span><span class='rparen'>)</span>
|
448
505
|
<span class='id identifier rubyid_console'><span class='object_link'><a href="top-level-namespace.html#console-instance_method" title="#console (method)">console</a></span></span><span class='period'>.</span><span class='id identifier rubyid_log'>log</span><span class='lparen'>(</span><span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>Ovto: </span><span class='tstring_end'>"</span></span><span class='op'>+</span><span class='id identifier rubyid_msg'>msg</span><span class='rparen'>)</span> <span class='kw'>if</span> <span class='ivar'>@debug_trace</span>
|
@@ -556,16 +613,16 @@
|
|
556
613
|
<pre class="lines">
|
557
614
|
|
558
615
|
|
559
|
-
27
|
560
|
-
28
|
561
616
|
29
|
562
617
|
30
|
563
618
|
31
|
564
619
|
32
|
565
|
-
33
|
620
|
+
33
|
621
|
+
34
|
622
|
+
35</pre>
|
566
623
|
</td>
|
567
624
|
<td>
|
568
|
-
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line
|
625
|
+
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line 29</span>
|
569
626
|
|
570
627
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_inspect'>inspect</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='rparen'>)</span>
|
571
628
|
<span class='kw'>if</span> <span class='backtick'>`</span><span class='tstring_content'>obj.$inspect</span><span class='tstring_end'>`</span></span>
|
@@ -606,8 +663,6 @@
|
|
606
663
|
<pre class="lines">
|
607
664
|
|
608
665
|
|
609
|
-
37
|
610
|
-
38
|
611
666
|
39
|
612
667
|
40
|
613
668
|
41
|
@@ -627,10 +682,12 @@
|
|
627
682
|
55
|
628
683
|
56
|
629
684
|
57
|
630
|
-
58
|
685
|
+
58
|
686
|
+
59
|
687
|
+
60</pre>
|
631
688
|
</td>
|
632
689
|
<td>
|
633
|
-
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line
|
690
|
+
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line 39</span>
|
634
691
|
|
635
692
|
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_log_error'>log_error</span><span class='lparen'>(</span><span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
636
693
|
<span class='kw'>return</span> <span class='id identifier rubyid_block'>block</span><span class='period'>.</span><span class='id identifier rubyid_call'>call</span>
|
@@ -657,6 +714,146 @@
|
|
657
714
|
</td>
|
658
715
|
</tr>
|
659
716
|
</table>
|
717
|
+
</div>
|
718
|
+
|
719
|
+
<div class="method_details ">
|
720
|
+
<h3 class="signature " id="Middleware-class_method">
|
721
|
+
|
722
|
+
.<strong>Middleware</strong>(name) ⇒ <tt>Object</tt>
|
723
|
+
|
724
|
+
|
725
|
+
|
726
|
+
|
727
|
+
|
728
|
+
</h3><div class="docstring">
|
729
|
+
<div class="discussion">
|
730
|
+
|
731
|
+
<p>Create an ancestor of middleware class Example:</p>
|
732
|
+
|
733
|
+
<pre class="code ruby"><code class="ruby">class MiddlewareExample < Ovto::Middleware("middleware_example")
|
734
|
+
</code></pre>
|
735
|
+
|
736
|
+
|
737
|
+
</div>
|
738
|
+
</div>
|
739
|
+
<div class="tags">
|
740
|
+
|
741
|
+
|
742
|
+
</div><table class="source_code">
|
743
|
+
<tr>
|
744
|
+
<td>
|
745
|
+
<pre class="lines">
|
746
|
+
|
747
|
+
|
748
|
+
6
|
749
|
+
7
|
750
|
+
8
|
751
|
+
9
|
752
|
+
10
|
753
|
+
11
|
754
|
+
12
|
755
|
+
13
|
756
|
+
14
|
757
|
+
15
|
758
|
+
16
|
759
|
+
17
|
760
|
+
18</pre>
|
761
|
+
</td>
|
762
|
+
<td>
|
763
|
+
<pre class="code"><span class="info file"># File 'lib/ovto/middleware.rb', line 6</span>
|
764
|
+
|
765
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='const'>Middleware</span><span class='lparen'>(</span><span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
766
|
+
<span class='kw'>unless</span> <span class='const'><span class='object_link'><a href="#VALID_NAME_REXP-constant" title="Ovto::VALID_NAME_REXP (constant)">VALID_NAME_REXP</a></span></span> <span class='op'>=~</span> <span class='id identifier rubyid_name'>name</span>
|
767
|
+
<span class='id identifier rubyid_raise'>raise</span> <span class='tstring'><span class='tstring_beg'>"</span><span class='tstring_content'>invalid middleware name: </span><span class='embexpr_beg'>#{</span><span class='id identifier rubyid_name'>name</span><span class='embexpr_end'>}</span><span class='tstring_end'>"</span></span>
|
768
|
+
<span class='kw'>end</span>
|
769
|
+
<span class='kw'>return</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="" title="Ovto (module)">Ovto</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Ovto/Middleware.html" title="Ovto::Middleware (module)">Middleware</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Ovto/Middleware/Base.html" title="Ovto::Middleware::Base (class)">Base</a></span></span><span class='rparen'>)</span><span class='lbrace'>{</span>
|
770
|
+
<span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='symbol'>:OVTO_MIDDLEWARE_NAME</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
771
|
+
<span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='symbol'>:State</span><span class='comma'>,</span> <span class='const'><span class='object_link'><a href="" title="Ovto (module)">Ovto</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Ovto/State.html" title="Ovto::State (class)">State</a></span></span><span class='rparen'>)</span>
|
772
|
+
<span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='symbol'>:Actions</span><span class='comma'>,</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="" title="Ovto (module)">Ovto</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Ovto/Middleware.html" title="Ovto::Middleware (module)">Middleware</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Ovto/Middleware/Actions.html" title="Ovto::Middleware::Actions (class)">Actions</a></span></span><span class='rparen'>)</span><span class='rparen'>)</span>
|
773
|
+
<span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='symbol'>:Actions</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='symbol'>:OVTO_MIDDLEWARE_NAME</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
774
|
+
<span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='symbol'>:Component</span><span class='comma'>,</span> <span class='const'>Class</span><span class='period'>.</span><span class='id identifier rubyid_new'>new</span><span class='lparen'>(</span><span class='const'><span class='object_link'><a href="" title="Ovto (module)">Ovto</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Ovto/Middleware.html" title="Ovto::Middleware (module)">Middleware</a></span></span><span class='op'>::</span><span class='const'><span class='object_link'><a href="Ovto/Middleware/Component.html" title="Ovto::Middleware::Component (class)">Component</a></span></span><span class='rparen'>)</span><span class='rparen'>)</span>
|
775
|
+
<span class='id identifier rubyid_const_get'>const_get</span><span class='lparen'>(</span><span class='symbol'>:Component</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_const_set'>const_set</span><span class='lparen'>(</span><span class='symbol'>:OVTO_MIDDLEWARE_NAME</span><span class='comma'>,</span> <span class='id identifier rubyid_name'>name</span><span class='rparen'>)</span>
|
776
|
+
<span class='rbrace'>}</span>
|
777
|
+
<span class='kw'>end</span></pre>
|
778
|
+
</td>
|
779
|
+
</tr>
|
780
|
+
</table>
|
781
|
+
</div>
|
782
|
+
|
783
|
+
<div class="method_details ">
|
784
|
+
<h3 class="signature " id="send_args_with_state-class_method">
|
785
|
+
|
786
|
+
.<strong>send_args_with_state</strong>(obj, meth, args, state, &block) ⇒ <tt>Object</tt>
|
787
|
+
|
788
|
+
|
789
|
+
|
790
|
+
|
791
|
+
|
792
|
+
</h3><div class="docstring">
|
793
|
+
<div class="discussion">
|
794
|
+
|
795
|
+
<p>Something like `obj.meth(state: state, **args, &block)` Safe even if
|
796
|
+
`obj.meth` does not have `state:`</p>
|
797
|
+
|
798
|
+
|
799
|
+
</div>
|
800
|
+
</div>
|
801
|
+
<div class="tags">
|
802
|
+
|
803
|
+
|
804
|
+
</div><table class="source_code">
|
805
|
+
<tr>
|
806
|
+
<td>
|
807
|
+
<pre class="lines">
|
808
|
+
|
809
|
+
|
810
|
+
64
|
811
|
+
65
|
812
|
+
66
|
813
|
+
67
|
814
|
+
68
|
815
|
+
69
|
816
|
+
70
|
817
|
+
71
|
818
|
+
72
|
819
|
+
73
|
820
|
+
74
|
821
|
+
75
|
822
|
+
76
|
823
|
+
77
|
824
|
+
78
|
825
|
+
79
|
826
|
+
80
|
827
|
+
81
|
828
|
+
82
|
829
|
+
83</pre>
|
830
|
+
</td>
|
831
|
+
<td>
|
832
|
+
<pre class="code"><span class="info file"># File 'lib/ovto.rb', line 64</span>
|
833
|
+
|
834
|
+
<span class='kw'>def</span> <span class='kw'>self</span><span class='period'>.</span><span class='id identifier rubyid_send_args_with_state'>send_args_with_state</span><span class='lparen'>(</span><span class='id identifier rubyid_obj'>obj</span><span class='comma'>,</span> <span class='id identifier rubyid_meth'>meth</span><span class='comma'>,</span> <span class='id identifier rubyid_args'>args</span><span class='comma'>,</span> <span class='id identifier rubyid_state'>state</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
835
|
+
<span class='id identifier rubyid_parameters'>parameters</span> <span class='op'>=</span> <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid_method'>method</span><span class='lparen'>(</span><span class='id identifier rubyid_meth'>meth</span><span class='rparen'>)</span><span class='period'>.</span><span class='id identifier rubyid_parameters'>parameters</span>
|
836
|
+
<span class='id identifier rubyid_accepts_state'>accepts_state</span> <span class='op'>=</span> <span class='backtick'>`</span><span class='tstring_content'>!parameters</span><span class='tstring_end'>`</span></span> <span class='op'>||</span> <span class='id identifier rubyid_parameters'>parameters</span><span class='period'>.</span><span class='id identifier rubyid_nil?'>nil?</span> <span class='op'>||</span> <span class='id identifier rubyid_parameters'>parameters</span><span class='period'>.</span><span class='id identifier rubyid_any?'>any?</span><span class='lbrace'>{</span><span class='op'>|</span><span class='id identifier rubyid_item'>item</span><span class='op'>|</span>
|
837
|
+
<span class='id identifier rubyid_item'>item</span> <span class='op'>==</span> <span class='lbracket'>[</span><span class='symbol'>:key</span><span class='comma'>,</span> <span class='symbol'>:state</span><span class='rbracket'>]</span> <span class='op'>||</span>
|
838
|
+
<span class='id identifier rubyid_item'>item</span> <span class='op'>==</span> <span class='lbracket'>[</span><span class='symbol'>:keyreq</span><span class='comma'>,</span> <span class='symbol'>:state</span><span class='rbracket'>]</span> <span class='op'>||</span>
|
839
|
+
<span class='id identifier rubyid_item'>item</span><span class='lbracket'>[</span><span class='int'>0</span><span class='rbracket'>]</span> <span class='op'>==</span> <span class='symbol'>:keyrest</span>
|
840
|
+
<span class='rbrace'>}</span>
|
841
|
+
<span class='kw'>if</span> <span class='id identifier rubyid_accepts_state'>accepts_state</span>
|
842
|
+
<span class='comment'># We can pass `state:` safely
|
843
|
+
</span> <span class='id identifier rubyid_args_with_state'>args_with_state</span> <span class='op'>=</span> <span class='lbrace'>{</span><span class='label'>state:</span> <span class='id identifier rubyid_state'>state</span><span class='rbrace'>}</span><span class='period'>.</span><span class='id identifier rubyid_merge'>merge</span><span class='lparen'>(</span><span class='id identifier rubyid_args'>args</span><span class='rparen'>)</span>
|
844
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid___send__'>__send__</span><span class='lparen'>(</span><span class='id identifier rubyid_meth'>meth</span><span class='comma'>,</span> <span class='id identifier rubyid_args_with_state'>args_with_state</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
845
|
+
<span class='kw'>else</span>
|
846
|
+
<span class='comment'># Check it is empty (see https://github.com/opal/opal/issues/1872)
|
847
|
+
</span> <span class='kw'>if</span> <span class='id identifier rubyid_args'>args</span><span class='period'>.</span><span class='id identifier rubyid_empty?'>empty?</span>
|
848
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid___send__'>__send__</span><span class='lparen'>(</span><span class='id identifier rubyid_meth'>meth</span><span class='comma'>,</span> <span class='op'>&</span><span class='id identifier rubyid_block'>block</span><span class='rparen'>)</span>
|
849
|
+
<span class='kw'>else</span>
|
850
|
+
<span class='kw'>return</span> <span class='id identifier rubyid_obj'>obj</span><span class='period'>.</span><span class='id identifier rubyid___send__'>__send__</span><span class='lparen'>(</span><span class='id identifier rubyid_meth'>meth</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_block'>block</span><span class='rparen'>)</span>
|
851
|
+
<span class='kw'>end</span>
|
852
|
+
<span class='kw'>end</span>
|
853
|
+
<span class='kw'>end</span></pre>
|
854
|
+
</td>
|
855
|
+
</tr>
|
856
|
+
</table>
|
660
857
|
</div>
|
661
858
|
|
662
859
|
</div>
|
@@ -664,9 +861,9 @@
|
|
664
861
|
</div>
|
665
862
|
|
666
863
|
<div id="footer">
|
667
|
-
Generated on
|
864
|
+
Generated on Fri Feb 28 23:42:46 2020 by
|
668
865
|
<a href="http://yardoc.org" title="Yay! A Ruby Documentation Tool" target="_parent">yard</a>
|
669
|
-
0.9.
|
866
|
+
0.9.24 (ruby-2.5.5).
|
670
867
|
</div>
|
671
868
|
|
672
869
|
</div>
|