wee 0.1.0 → 0.3.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (193) hide show
  1. data/INSTALL +7 -0
  2. data/README +268 -0
  3. data/Rakefile +26 -0
  4. data/TODO +116 -0
  5. data/benchmark/Centrino1300/result.2000.counter.action +45 -0
  6. data/benchmark/Centrino1300/result.2000.counter.render +43 -0
  7. data/benchmark/Centrino1300/result.2000.filehandler +43 -0
  8. data/benchmark/Centrino600/result.2000.counter.action +47 -0
  9. data/benchmark/Centrino600/result.2000.counter.render +45 -0
  10. data/benchmark/Centrino600/result.2000.filehandler +43 -0
  11. data/benchmark/Makefile +48 -0
  12. data/benchmark/bench.sh +24 -0
  13. data/benchmark/counter.rb +96 -0
  14. data/benchmark/filehandler.rb +6 -0
  15. data/doc/rdoc/classes/Array.html +172 -0
  16. data/doc/rdoc/classes/Cache.html +126 -0
  17. data/doc/rdoc/classes/Cache/StorageCache.html +320 -0
  18. data/doc/rdoc/classes/Cache/Strategy.html +128 -0
  19. data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +269 -0
  20. data/doc/rdoc/classes/Cache/Strategy/LFU.html +238 -0
  21. data/doc/rdoc/classes/Cache/Strategy/LFU/Item.html +111 -0
  22. data/doc/rdoc/classes/Cache/Strategy/LRU.html +238 -0
  23. data/doc/rdoc/classes/Cache/Strategy/LRU/Item.html +111 -0
  24. data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +225 -0
  25. data/doc/rdoc/classes/Cache/Strategy/Unbounded/Item.html +111 -0
  26. data/doc/rdoc/classes/Enumerable.html +146 -0
  27. data/doc/rdoc/classes/LiteralMethod.html +196 -0
  28. data/doc/rdoc/classes/Object.html +178 -0
  29. data/doc/rdoc/classes/String.html +172 -0
  30. data/doc/rdoc/classes/Struct.html +174 -0
  31. data/doc/rdoc/classes/Wee.html +160 -0
  32. data/doc/rdoc/classes/Wee/AnswerDecoration.html +182 -0
  33. data/doc/rdoc/classes/Wee/Application.html +337 -0
  34. data/doc/rdoc/classes/Wee/Brush.html +245 -0
  35. data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +149 -0
  36. data/doc/rdoc/classes/Wee/Brush/ActionMixin.html +146 -0
  37. data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +157 -0
  38. data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +210 -0
  39. data/doc/rdoc/classes/Wee/Brush/AssignMixin.html +141 -0
  40. data/doc/rdoc/classes/Wee/Brush/CallbackMixin.html +141 -0
  41. data/doc/rdoc/classes/Wee/Brush/FormTag.html +225 -0
  42. data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +176 -0
  43. data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +283 -0
  44. data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +176 -0
  45. data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +195 -0
  46. data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +149 -0
  47. data/doc/rdoc/classes/Wee/Brush/InputTag.html +172 -0
  48. data/doc/rdoc/classes/Wee/Brush/Page.html +193 -0
  49. data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +267 -0
  50. data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +177 -0
  51. data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +154 -0
  52. data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +173 -0
  53. data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +146 -0
  54. data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +277 -0
  55. data/doc/rdoc/classes/Wee/Brush/TableTag.html +146 -0
  56. data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +229 -0
  57. data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +154 -0
  58. data/doc/rdoc/classes/Wee/Callback.html +231 -0
  59. data/doc/rdoc/classes/Wee/CallbackRegistry.html +308 -0
  60. data/doc/rdoc/classes/Wee/CallbackStream.html +227 -0
  61. data/doc/rdoc/classes/Wee/Canvas.html +235 -0
  62. data/doc/rdoc/classes/Wee/Component.html +933 -0
  63. data/doc/rdoc/classes/Wee/Context.html +111 -0
  64. data/doc/rdoc/classes/Wee/Decoration.html +338 -0
  65. data/doc/rdoc/classes/Wee/Delegate.html +247 -0
  66. data/doc/rdoc/classes/Wee/ErrorPage.html +175 -0
  67. data/doc/rdoc/classes/Wee/ErrorResponse.html +180 -0
  68. data/doc/rdoc/classes/Wee/GenericResponse.html +162 -0
  69. data/doc/rdoc/classes/Wee/HtmlCanvas.html +751 -0
  70. data/doc/rdoc/classes/Wee/HtmlWriter.html +351 -0
  71. data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +180 -0
  72. data/doc/rdoc/classes/Wee/MethodCallback.html +193 -0
  73. data/doc/rdoc/classes/Wee/Page.html +111 -0
  74. data/doc/rdoc/classes/Wee/Presenter.html +521 -0
  75. data/doc/rdoc/classes/Wee/RedirectResponse.html +150 -0
  76. data/doc/rdoc/classes/Wee/RefreshResponse.html +157 -0
  77. data/doc/rdoc/classes/Wee/RenderingContext.html +111 -0
  78. data/doc/rdoc/classes/Wee/Request.html +268 -0
  79. data/doc/rdoc/classes/Wee/RequestHandler.html +336 -0
  80. data/doc/rdoc/classes/Wee/Response.html +260 -0
  81. data/doc/rdoc/classes/Wee/Session.html +469 -0
  82. data/doc/rdoc/classes/Wee/SimpleIdGenerator.html +198 -0
  83. data/doc/rdoc/classes/Wee/Snapshot.html +211 -0
  84. data/doc/rdoc/classes/Wee/StateHolder.html +149 -0
  85. data/doc/rdoc/classes/Wee/StateRegistry.html +434 -0
  86. data/doc/rdoc/classes/Wee/StateRegistry/Snapshot.html +320 -0
  87. data/doc/rdoc/classes/Wee/StateRegistry/WithObject.html +153 -0
  88. data/doc/rdoc/classes/Wee/Utils.html +111 -0
  89. data/doc/rdoc/classes/Wee/Utils/LRUCache.html +148 -0
  90. data/doc/rdoc/classes/Wee/ValueHolder.html +220 -0
  91. data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +330 -0
  92. data/doc/rdoc/created.rid +1 -0
  93. data/doc/rdoc/files/INSTALL.html +118 -0
  94. data/doc/rdoc/files/README.html +466 -0
  95. data/doc/rdoc/files/lib/cache/cache_rb.html +101 -0
  96. data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +108 -0
  97. data/doc/rdoc/files/lib/wee/application_rb.html +112 -0
  98. data/doc/rdoc/files/lib/wee/callback_rb.html +107 -0
  99. data/doc/rdoc/files/lib/wee/component_ext_rb.html +101 -0
  100. data/doc/rdoc/files/lib/wee/component_rb.html +109 -0
  101. data/doc/rdoc/files/lib/wee/context_rb.html +101 -0
  102. data/doc/rdoc/files/lib/wee/core/callback_rb.html +115 -0
  103. data/doc/rdoc/files/lib/wee/core/component_rb.html +108 -0
  104. data/doc/rdoc/files/lib/wee/core/decoration_rb.html +133 -0
  105. data/doc/rdoc/files/lib/wee/core/presenter_rb.html +112 -0
  106. data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +113 -0
  107. data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +110 -0
  108. data/doc/rdoc/files/lib/wee/core_rb.html +131 -0
  109. data/doc/rdoc/files/lib/wee/decoration_rb.html +101 -0
  110. data/doc/rdoc/files/lib/wee/holder_rb.html +101 -0
  111. data/doc/rdoc/files/lib/wee/html_canvas_rb.html +108 -0
  112. data/doc/rdoc/files/lib/wee/html_writer_rb.html +108 -0
  113. data/doc/rdoc/files/lib/wee/idgen_rb.html +101 -0
  114. data/doc/rdoc/files/lib/wee/page_rb.html +101 -0
  115. data/doc/rdoc/files/lib/wee/presenter_rb.html +112 -0
  116. data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +101 -0
  117. data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +101 -0
  118. data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +108 -0
  119. data/doc/rdoc/files/lib/wee/rendering/html/brushes_rb.html +101 -0
  120. data/doc/rdoc/files/lib/wee/rendering/html/canvas_rb.html +101 -0
  121. data/doc/rdoc/files/lib/wee/rendering/html/writer_rb.html +108 -0
  122. data/doc/rdoc/files/lib/wee/request_rb.html +113 -0
  123. data/doc/rdoc/files/lib/wee/requesthandler_rb.html +101 -0
  124. data/doc/rdoc/files/lib/wee/response_rb.html +108 -0
  125. data/doc/rdoc/files/lib/wee/session_rb.html +109 -0
  126. data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +101 -0
  127. data/doc/rdoc/files/lib/wee/snapshot_rb.html +107 -0
  128. data/doc/rdoc/files/lib/wee/state_registry_rb.html +110 -0
  129. data/doc/rdoc/files/lib/wee/stuff_rb.html +144 -0
  130. data/doc/rdoc/files/lib/wee/utils/cache_rb.html +108 -0
  131. data/doc/rdoc/files/lib/wee/webrick_rb.html +108 -0
  132. data/doc/rdoc/files/lib/wee_rb.html +132 -0
  133. data/doc/rdoc/fr_class_index.html +93 -0
  134. data/doc/rdoc/fr_file_index.html +51 -0
  135. data/doc/rdoc/fr_method_index.html +242 -0
  136. data/doc/rdoc/index.html +24 -0
  137. data/doc/rdoc/rdoc-style.css +208 -0
  138. data/examples/ObjectSpaceBrowser.rb +199 -0
  139. data/examples/calendar.rb +366 -0
  140. data/examples/cc.rb +94 -0
  141. data/examples/draw.rb +91 -0
  142. data/examples/example.rb +223 -0
  143. data/examples/test.rb +66 -0
  144. data/examples/window.rb +53 -0
  145. data/lib/cache/cache.rb +9 -0
  146. data/lib/wee.rb +18 -8
  147. data/lib/wee/adaptors/webrick.rb +73 -0
  148. data/lib/wee/application.rb +69 -71
  149. data/lib/wee/context.rb +2 -12
  150. data/lib/wee/core.rb +15 -0
  151. data/lib/wee/core/callback.rb +108 -0
  152. data/lib/wee/core/component.rb +314 -0
  153. data/lib/wee/core/decoration.rb +129 -0
  154. data/lib/wee/core/presenter.rb +132 -0
  155. data/lib/wee/core/snapshot.rb +21 -0
  156. data/lib/wee/core/valueholder.rb +19 -0
  157. data/lib/wee/idgen.rb +13 -0
  158. data/lib/wee/page.rb +1 -1
  159. data/lib/wee/renderer/html/brushes.rb +435 -0
  160. data/lib/wee/renderer/html/canvas.rb +148 -0
  161. data/lib/wee/{html_writer.rb → renderer/html/writer.rb} +31 -16
  162. data/lib/wee/request.rb +57 -0
  163. data/lib/wee/requesthandler.rb +77 -0
  164. data/lib/wee/response.rb +77 -0
  165. data/lib/wee/session.rb +70 -64
  166. data/lib/wee/{snapshot.rb → snapshot_ext.rb} +4 -4
  167. data/test/components/calltest.rb +16 -0
  168. data/test/components/counter.rb +17 -0
  169. data/test/components/messagebox.rb +15 -0
  170. data/test/components/page.rb +14 -0
  171. data/test/components/page_decoration.rb +7 -0
  172. data/test/stress.rb +64 -0
  173. data/test/test_component.rb +106 -0
  174. data/test/test_html_canvas.rb +25 -0
  175. data/test/test_html_writer.rb +27 -0
  176. data/test/test_request.rb +13 -0
  177. data/test/utils/cross.rb +65 -0
  178. data/test/utils/generic_plotter.rb +28 -0
  179. data/test/utils/gnuplot.rb +31 -0
  180. data/test/utils/measure_memory.rb +9 -0
  181. data/test/utils/memory_plotter.rb +10 -0
  182. data/test/utils/object_plotter.rb +10 -0
  183. data/test/utils/webrick_background.rb +31 -0
  184. data/wee.gemspec +22 -0
  185. metadata +222 -18
  186. data/lib/wee/component.rb +0 -126
  187. data/lib/wee/delegate_decoration.rb +0 -22
  188. data/lib/wee/handler_registry.rb +0 -89
  189. data/lib/wee/holder.rb +0 -14
  190. data/lib/wee/html_canvas.rb +0 -379
  191. data/lib/wee/state_registry.rb +0 -173
  192. data/lib/wee/stuff.rb +0 -29
  193. data/lib/wee/webrick.rb +0 -15
@@ -0,0 +1,235 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Wee::Canvas</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Wee::Canvas</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/wee/renderer/html/canvas_rb.html">
59
+ lib/wee/renderer/html/canvas.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="../Object.html">
69
+ Object
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+
84
+
85
+ </div>
86
+
87
+ <div id="method-list">
88
+ <h3 class="section-bar">Methods</h3>
89
+
90
+ <div class="name-list">
91
+ <a href="#M000153">close</a>&nbsp;&nbsp;
92
+ <a href="#M000155">nest</a>&nbsp;&nbsp;
93
+ <a href="#M000152">new</a>&nbsp;&nbsp;
94
+ <a href="#M000154">set_brush</a>&nbsp;&nbsp;
95
+ </div>
96
+ </div>
97
+
98
+ </div>
99
+
100
+
101
+ <!-- if includes -->
102
+
103
+ <div id="section">
104
+
105
+
106
+
107
+
108
+
109
+
110
+
111
+
112
+ <!-- if method_list -->
113
+ <div id="methods">
114
+ <h3 class="section-bar">Public Class methods</h3>
115
+
116
+ <div id="method-M000152" class="method-detail">
117
+ <a name="M000152"></a>
118
+
119
+ <div class="method-heading">
120
+ <a href="#M000152" class="method-signature">
121
+ <span class="method-name">new</span><span class="method-args">()</span>
122
+ </a>
123
+ </div>
124
+
125
+ <div class="method-description">
126
+ <p><a class="source-toggle" href="#"
127
+ onclick="toggleCode('M000152-source');return false;">[Source]</a></p>
128
+ <div class="method-source-code" id="M000152-source">
129
+ <pre>
130
+ <span class="ruby-comment cmt"># File lib/wee/renderer/html/canvas.rb, line 4</span>
131
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>
132
+ <span class="ruby-ivar">@parent_brush</span> = <span class="ruby-keyword kw">nil</span>
133
+ <span class="ruby-ivar">@current_brush</span> = <span class="ruby-keyword kw">nil</span>
134
+ <span class="ruby-keyword kw">end</span>
135
+ </pre>
136
+ </div>
137
+ </div>
138
+ </div>
139
+
140
+ <h3 class="section-bar">Public Instance methods</h3>
141
+
142
+ <div id="method-M000153" class="method-detail">
143
+ <a name="M000153"></a>
144
+
145
+ <div class="method-heading">
146
+ <a href="#M000153" class="method-signature">
147
+ <span class="method-name">close</span><span class="method-args">()</span>
148
+ </a>
149
+ </div>
150
+
151
+ <div class="method-description">
152
+ <p><a class="source-toggle" href="#"
153
+ onclick="toggleCode('M000153-source');return false;">[Source]</a></p>
154
+ <div class="method-source-code" id="M000153-source">
155
+ <pre>
156
+ <span class="ruby-comment cmt"># File lib/wee/renderer/html/canvas.rb, line 9</span>
157
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">close</span>
158
+ <span class="ruby-ivar">@current_brush</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@current_brush</span>
159
+ <span class="ruby-ivar">@current_brush</span> = <span class="ruby-keyword kw">nil</span>
160
+ <span class="ruby-keyword kw">end</span>
161
+ </pre>
162
+ </div>
163
+ </div>
164
+ </div>
165
+
166
+ <div id="method-M000155" class="method-detail">
167
+ <a name="M000155"></a>
168
+
169
+ <div class="method-heading">
170
+ <a href="#M000155" class="method-signature">
171
+ <span class="method-name">nest</span><span class="method-args">(&amp;block)</span>
172
+ </a>
173
+ </div>
174
+
175
+ <div class="method-description">
176
+ <p><a class="source-toggle" href="#"
177
+ onclick="toggleCode('M000155-source');return false;">[Source]</a></p>
178
+ <div class="method-source-code" id="M000155-source">
179
+ <pre>
180
+ <span class="ruby-comment cmt"># File lib/wee/renderer/html/canvas.rb, line 25</span>
181
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">nest</span>(<span class="ruby-operator">&amp;</span><span class="ruby-identifier">block</span>)
182
+ <span class="ruby-ivar">@parent_brush</span> = <span class="ruby-ivar">@current_brush</span>
183
+ <span class="ruby-ivar">@current_brush</span> = <span class="ruby-keyword kw">nil</span>
184
+ <span class="ruby-identifier">block</span>.<span class="ruby-identifier">call</span>
185
+ <span class="ruby-ivar">@current_brush</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@current_brush</span>
186
+ <span class="ruby-ivar">@parent_brush</span> = <span class="ruby-ivar">@parent_brush</span>.<span class="ruby-identifier">parent</span>
187
+ <span class="ruby-keyword kw">end</span>
188
+ </pre>
189
+ </div>
190
+ </div>
191
+ </div>
192
+
193
+ <div id="method-M000154" class="method-detail">
194
+ <a name="M000154"></a>
195
+
196
+ <div class="method-heading">
197
+ <a href="#M000154" class="method-signature">
198
+ <span class="method-name">set_brush</span><span class="method-args">(brush)</span>
199
+ </a>
200
+ </div>
201
+
202
+ <div class="method-description">
203
+ <p><a class="source-toggle" href="#"
204
+ onclick="toggleCode('M000154-source');return false;">[Source]</a></p>
205
+ <div class="method-source-code" id="M000154-source">
206
+ <pre>
207
+ <span class="ruby-comment cmt"># File lib/wee/renderer/html/canvas.rb, line 14</span>
208
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">set_brush</span>(<span class="ruby-identifier">brush</span>)
209
+ <span class="ruby-comment cmt"># tell previous brush to finish</span>
210
+ <span class="ruby-ivar">@current_brush</span>.<span class="ruby-identifier">close</span> <span class="ruby-keyword kw">if</span> <span class="ruby-ivar">@current_brush</span>
211
+
212
+ <span class="ruby-identifier">brush</span>.<span class="ruby-identifier">parent</span> = <span class="ruby-ivar">@parent_brush</span>
213
+ <span class="ruby-identifier">brush</span>.<span class="ruby-identifier">canvas</span> = <span class="ruby-keyword kw">self</span>
214
+ <span class="ruby-ivar">@current_brush</span> = <span class="ruby-identifier">brush</span>
215
+
216
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">brush</span>
217
+ <span class="ruby-keyword kw">end</span>
218
+ </pre>
219
+ </div>
220
+ </div>
221
+ </div>
222
+
223
+
224
+ </div>
225
+
226
+
227
+ </div>
228
+
229
+
230
+ <div id="validator-badges">
231
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
232
+ </div>
233
+
234
+ </body>
235
+ </html>
@@ -0,0 +1,933 @@
1
+ <?xml version="1.0" encoding="iso-8859-1"?>
2
+ <!DOCTYPE html
3
+ PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
4
+ "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
5
+
6
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
7
+ <head>
8
+ <title>Class: Wee::Component</title>
9
+ <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
10
+ <meta http-equiv="Content-Script-Type" content="text/javascript" />
11
+ <link rel="stylesheet" href="../.././rdoc-style.css" type="text/css" media="screen" />
12
+ <script type="text/javascript">
13
+ // <![CDATA[
14
+
15
+ function popupCode( url ) {
16
+ window.open(url, "Code", "resizable=yes,scrollbars=yes,toolbar=no,status=no,height=150,width=400")
17
+ }
18
+
19
+ function toggleCode( id ) {
20
+ if ( document.getElementById )
21
+ elem = document.getElementById( id );
22
+ else if ( document.all )
23
+ elem = eval( "document.all." + id );
24
+ else
25
+ return false;
26
+
27
+ elemStyle = elem.style;
28
+
29
+ if ( elemStyle.display != "block" ) {
30
+ elemStyle.display = "block"
31
+ } else {
32
+ elemStyle.display = "none"
33
+ }
34
+
35
+ return true;
36
+ }
37
+
38
+ // Make codeblocks hidden by default
39
+ document.writeln( "<style type=\"text/css\">div.method-source-code { display: none }</style>" )
40
+
41
+ // ]]>
42
+ </script>
43
+
44
+ </head>
45
+ <body>
46
+
47
+
48
+
49
+ <div id="classHeader">
50
+ <table class="header-table">
51
+ <tr class="top-aligned-row">
52
+ <td><strong>Class</strong></td>
53
+ <td class="class-name-in-header">Wee::Component</td>
54
+ </tr>
55
+ <tr class="top-aligned-row">
56
+ <td><strong>In:</strong></td>
57
+ <td>
58
+ <a href="../../files/lib/wee/core/component_rb.html">
59
+ lib/wee/core/component.rb
60
+ </a>
61
+ <br />
62
+ </td>
63
+ </tr>
64
+
65
+ <tr class="top-aligned-row">
66
+ <td><strong>Parent:</strong></td>
67
+ <td>
68
+ <a href="Presenter.html">
69
+ Wee::Presenter
70
+ </a>
71
+ </td>
72
+ </tr>
73
+ </table>
74
+ </div>
75
+ <!-- banner header -->
76
+
77
+ <div id="bodyContent">
78
+
79
+
80
+
81
+ <div id="contextContent">
82
+
83
+ <div id="description">
84
+ <p>
85
+ The base class of all components. You should at least overwrite method <a
86
+ href="Component.html#M000164">render</a> in your own subclasses.
87
+ </p>
88
+
89
+ </div>
90
+
91
+
92
+ <div id="contents-list">
93
+ <h3 class="section-bar">Contents</h3>
94
+ <ul>
95
+ <li><a href="#SEC00063">Render</a></li>
96
+ <li><a href="#SEC00064">Callback</a></li>
97
+ <li><a href="#SEC00065">Init</a></li>
98
+ <li><a href="#SEC00066">Children</a></li>
99
+ <li><a href="#SEC00067">Decoration</a></li>
100
+ <li><a href="#SEC00068">Backtrack</a></li>
101
+ <li><a href="#SEC00069">Call/Answer</a></li>
102
+ </ul>
103
+ </div>
104
+
105
+ <div id="method-list">
106
+ <h3 class="section-bar">Methods</h3>
107
+
108
+ <div class="name-list">
109
+ <a href="#M000169">add_child</a>&nbsp;&nbsp;
110
+ <a href="#M000173">add_decoration</a>&nbsp;&nbsp;
111
+ <a href="#M000179">answer</a>&nbsp;&nbsp;
112
+ <a href="#M000177">backtrack_state</a>&nbsp;&nbsp;
113
+ <a href="#M000176">backtrack_state_chain</a>&nbsp;&nbsp;
114
+ <a href="#M000178">call</a>&nbsp;&nbsp;
115
+ <a href="#M000168">children</a>&nbsp;&nbsp;
116
+ <a href="#M000170">decoration</a>&nbsp;&nbsp;
117
+ <a href="#M000171">decoration=</a>&nbsp;&nbsp;
118
+ <a href="#M000163">do_render_chain</a>&nbsp;&nbsp;
119
+ <a href="#M000172">each_decoration</a>&nbsp;&nbsp;
120
+ <a href="#M000167">initialize</a>&nbsp;&nbsp;
121
+ <a href="#M000166">process_callbacks</a>&nbsp;&nbsp;
122
+ <a href="#M000165">process_callbacks_chain</a>&nbsp;&nbsp;
123
+ <a href="#M000174">remove_decoration</a>&nbsp;&nbsp;
124
+ <a href="#M000175">remove_decoration_if</a>&nbsp;&nbsp;
125
+ <a href="#M000164">render</a>&nbsp;&nbsp;
126
+ </div>
127
+ </div>
128
+
129
+ </div>
130
+
131
+
132
+ <!-- if includes -->
133
+
134
+ <div id="section">
135
+
136
+
137
+
138
+
139
+
140
+
141
+
142
+
143
+ <!-- if method_list -->
144
+ <div id="section">
145
+ <h2 class="section-title"><a name="SEC00063">Render</a></h2>
146
+ <div class="section-comment">
147
+
148
+ </div>
149
+
150
+
151
+
152
+
153
+
154
+
155
+
156
+
157
+ <!-- if method_list -->
158
+ <div id="methods">
159
+ <h3 class="section-bar">Public Instance methods</h3>
160
+
161
+ <div id="method-M000163" class="method-detail">
162
+ <a name="M000163"></a>
163
+
164
+ <div class="method-heading">
165
+ <a href="#M000163" class="method-signature">
166
+ <span class="method-name">do_render_chain</span><span class="method-args">(rendering_context)</span>
167
+ </a>
168
+ </div>
169
+
170
+ <div class="method-description">
171
+ <p>
172
+ Starts rendering the decoration chain by calling method <a
173
+ href="Presenter.html#M000182">Presenter#do_render</a> for the first
174
+ decoration of the component, or calling <em>do_render</em> for the
175
+ component itself if no decorations were specified.
176
+ </p>
177
+ <dl>
178
+ <dt><tt>rendering_context</tt></dt><dd>An object of class <a href="RenderingContext.html">RenderingContext</a>
179
+
180
+ </dd>
181
+ </dl>
182
+ <p><a class="source-toggle" href="#"
183
+ onclick="toggleCode('M000163-source');return false;">[Source]</a></p>
184
+ <div class="method-source-code" id="M000163-source">
185
+ <pre>
186
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 19</span>
187
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">do_render_chain</span>(<span class="ruby-identifier">rendering_context</span>)
188
+ <span class="ruby-identifier">decoration</span>.<span class="ruby-identifier">do_render</span>(<span class="ruby-identifier">rendering_context</span>)
189
+ <span class="ruby-keyword kw">end</span>
190
+ </pre>
191
+ </div>
192
+ </div>
193
+ </div>
194
+
195
+ <div id="method-M000164" class="method-detail">
196
+ <a name="M000164"></a>
197
+
198
+ <div class="method-heading">
199
+ <a href="#M000164" class="method-signature">
200
+ <span class="method-name">render</span><span class="method-args">()</span>
201
+ </a>
202
+ </div>
203
+
204
+ <div class="method-description">
205
+ <p>
206
+ This method renders the content of this component.
207
+ </p>
208
+ <p>
209
+ <b>OVERWRITE</b> this method in your own component class to implement the
210
+ view. By default this method does nothing!
211
+ </p>
212
+ <p>
213
+ Use the current renderer as returned by renderer or it&#8217;s short-cut r.
214
+ </p>
215
+ <p><a class="source-toggle" href="#"
216
+ onclick="toggleCode('M000164-source');return false;">[Source]</a></p>
217
+ <div class="method-source-code" id="M000164-source">
218
+ <pre>
219
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 30</span>
220
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">render</span>
221
+ <span class="ruby-keyword kw">end</span>
222
+ </pre>
223
+ </div>
224
+ </div>
225
+ </div>
226
+
227
+
228
+ </div>
229
+ <div id="section">
230
+ <h2 class="section-title"><a name="SEC00064">Callback</a></h2>
231
+ <div class="section-comment">
232
+
233
+ </div>
234
+
235
+
236
+
237
+
238
+
239
+
240
+
241
+
242
+ <!-- if method_list -->
243
+ <div id="methods">
244
+ <h3 class="section-bar">Public Instance methods</h3>
245
+
246
+ <div id="method-M000166" class="method-detail">
247
+ <a name="M000166"></a>
248
+
249
+ <div class="method-heading">
250
+ <a href="#M000166" class="method-signature">
251
+ <span class="method-name">process_callbacks</span><span class="method-args">(callback_stream)</span>
252
+ </a>
253
+ </div>
254
+
255
+ <div class="method-description">
256
+ <p>
257
+ Process and invoke all callbacks specified for this component and all of
258
+ it&#8217;s child components.
259
+ </p>
260
+ <p>
261
+ All input callbacks of this component and it&#8217;s child components are
262
+ processed/invoked before any of the action callbacks are processed/invoked.
263
+ </p>
264
+ <dl>
265
+ <dt><tt>callback_stream</tt></dt><dd>An object of class <a href="CallbackStream.html">CallbackStream</a>
266
+
267
+ </dd>
268
+ </dl>
269
+ <p><a class="source-toggle" href="#"
270
+ onclick="toggleCode('M000166-source');return false;">[Source]</a></p>
271
+ <div class="method-source-code" id="M000166-source">
272
+ <pre>
273
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 59</span>
274
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_callbacks</span>(<span class="ruby-identifier">callback_stream</span>)
275
+ <span class="ruby-keyword kw">super</span> <span class="ruby-keyword kw">do</span>
276
+ <span class="ruby-comment cmt"># process callbacks of all children</span>
277
+ <span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span>
278
+ <span class="ruby-identifier">child</span>.<span class="ruby-identifier">process_callbacks_chain</span>(<span class="ruby-identifier">callback_stream</span>)
279
+ <span class="ruby-keyword kw">end</span>
280
+ <span class="ruby-keyword kw">end</span>
281
+ <span class="ruby-keyword kw">end</span>
282
+ </pre>
283
+ </div>
284
+ </div>
285
+ </div>
286
+
287
+ <div id="method-M000165" class="method-detail">
288
+ <a name="M000165"></a>
289
+
290
+ <div class="method-heading">
291
+ <a href="#M000165" class="method-signature">
292
+ <span class="method-name">process_callbacks_chain</span><span class="method-args">(callback_stream)</span>
293
+ </a>
294
+ </div>
295
+
296
+ <div class="method-description">
297
+ <p>
298
+ Starts processing the callbacks for the decoration chain by invoking method
299
+ <a href="Component.html#M000166">process_callbacks</a> of the first
300
+ decoration or the component itself if no decorations were specified.
301
+ </p>
302
+ <dl>
303
+ <dt><tt>callback_stream</tt></dt><dd>An object of class <a href="CallbackStream.html">CallbackStream</a>
304
+
305
+ </dd>
306
+ </dl>
307
+ <p><a class="source-toggle" href="#"
308
+ onclick="toggleCode('M000165-source');return false;">[Source]</a></p>
309
+ <div class="method-source-code" id="M000165-source">
310
+ <pre>
311
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 46</span>
312
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">process_callbacks_chain</span>(<span class="ruby-identifier">callback_stream</span>)
313
+ <span class="ruby-identifier">decoration</span>.<span class="ruby-identifier">process_callbacks</span>(<span class="ruby-identifier">callback_stream</span>)
314
+ <span class="ruby-keyword kw">end</span>
315
+ </pre>
316
+ </div>
317
+ </div>
318
+ </div>
319
+
320
+
321
+ </div>
322
+ <div id="section">
323
+ <h2 class="section-title"><a name="SEC00065">Init</a></h2>
324
+ <div class="section-comment">
325
+
326
+ </div>
327
+
328
+
329
+
330
+
331
+
332
+
333
+
334
+
335
+ <!-- if method_list -->
336
+ <div id="methods">
337
+ <h3 class="section-bar">Protected Instance methods</h3>
338
+
339
+ <div id="method-M000167" class="method-detail">
340
+ <a name="M000167"></a>
341
+
342
+ <div class="method-heading">
343
+ <a href="#M000167" class="method-signature">
344
+ <span class="method-name">initialize</span><span class="method-args">()</span>
345
+ </a>
346
+ </div>
347
+
348
+ <div class="method-description">
349
+ <p>
350
+ Initializes a newly created component.
351
+ </p>
352
+ <p>
353
+ Call this method from your own components&#8217; <em>initialize</em> method
354
+ using <tt>super</tt>, before setting up anything else!
355
+ </p>
356
+ <p><a class="source-toggle" href="#"
357
+ onclick="toggleCode('M000167-source');return false;">[Source]</a></p>
358
+ <div class="method-source-code" id="M000167-source">
359
+ <pre>
360
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 79</span>
361
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">initialize</span>() <span class="ruby-comment cmt"># :notnew:</span>
362
+ <span class="ruby-ivar">@decoration</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">ValueHolder</span>.<span class="ruby-identifier">new</span>(<span class="ruby-keyword kw">self</span>)
363
+ <span class="ruby-ivar">@children</span> = []
364
+ <span class="ruby-keyword kw">end</span>
365
+ </pre>
366
+ </div>
367
+ </div>
368
+ </div>
369
+
370
+
371
+ </div>
372
+ <div id="section">
373
+ <h2 class="section-title"><a name="SEC00066">Children</a></h2>
374
+ <div class="section-comment">
375
+
376
+ </div>
377
+
378
+
379
+
380
+
381
+
382
+
383
+
384
+
385
+ <!-- if method_list -->
386
+ <div id="methods">
387
+ <h3 class="section-bar">Protected Instance methods</h3>
388
+
389
+ <div id="method-M000169" class="method-detail">
390
+ <a name="M000169"></a>
391
+
392
+ <div class="method-heading">
393
+ <a href="#M000169" class="method-signature">
394
+ <span class="method-name">add_child</span><span class="method-args">(child)</span>
395
+ </a>
396
+ </div>
397
+
398
+ <div class="method-description">
399
+ <p>
400
+ Add a child to the component. Example:
401
+ </p>
402
+ <pre>
403
+ class YourComponent &lt; Wee::Component
404
+ def initialize
405
+ super()
406
+ add_child ChildComponent.new
407
+ end
408
+ end
409
+ </pre>
410
+ <p>
411
+ If you dynamically add child components to a component at run-time (not in
412
+ initialize), then you should consider to backtrack the children array (of
413
+ course only if you want backtracking at all):
414
+ </p>
415
+ <pre>
416
+ def backtrack_state(snapshot)
417
+ super
418
+ snapshot.add(self.children)
419
+ end
420
+ </pre>
421
+ <p><a class="source-toggle" href="#"
422
+ onclick="toggleCode('M000169-source');return false;">[Source]</a></p>
423
+ <div class="method-source-code" id="M000169-source">
424
+ <pre>
425
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 115</span>
426
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_child</span>(<span class="ruby-identifier">child</span>)
427
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">children</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">child</span>
428
+ <span class="ruby-keyword kw">end</span>
429
+ </pre>
430
+ </div>
431
+ </div>
432
+ </div>
433
+
434
+ <div id="method-M000168" class="method-detail">
435
+ <a name="M000168"></a>
436
+
437
+ <div class="method-heading">
438
+ <a href="#M000168" class="method-signature">
439
+ <span class="method-name">children</span><span class="method-args">()</span>
440
+ </a>
441
+ </div>
442
+
443
+ <div class="method-description">
444
+ <p>
445
+ Returns all direct child components collected in an array.
446
+ </p>
447
+ <p><a class="source-toggle" href="#"
448
+ onclick="toggleCode('M000168-source');return false;">[Source]</a></p>
449
+ <div class="method-source-code" id="M000168-source">
450
+ <pre>
451
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 92</span>
452
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">children</span>
453
+ <span class="ruby-ivar">@children</span>
454
+ <span class="ruby-keyword kw">end</span>
455
+ </pre>
456
+ </div>
457
+ </div>
458
+ </div>
459
+
460
+
461
+ </div>
462
+ <div id="section">
463
+ <h2 class="section-title"><a name="SEC00067">Decoration</a></h2>
464
+ <div class="section-comment">
465
+
466
+ </div>
467
+
468
+
469
+
470
+
471
+
472
+
473
+
474
+
475
+ <!-- if method_list -->
476
+ <div id="methods">
477
+ <h3 class="section-bar">Public Instance methods</h3>
478
+
479
+ <div id="method-M000173" class="method-detail">
480
+ <a name="M000173"></a>
481
+
482
+ <div class="method-heading">
483
+ <a href="#M000173" class="method-signature">
484
+ <span class="method-name">add_decoration</span><span class="method-args">(d)</span>
485
+ </a>
486
+ </div>
487
+
488
+ <div class="method-description">
489
+ <p>
490
+ Adds decoration <tt>d</tt> in front of the decoration chain.
491
+ </p>
492
+ <p><a class="source-toggle" href="#"
493
+ onclick="toggleCode('M000173-source');return false;">[Source]</a></p>
494
+ <div class="method-source-code" id="M000173-source">
495
+ <pre>
496
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 151</span>
497
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">add_decoration</span>(<span class="ruby-identifier">d</span>)
498
+ <span class="ruby-identifier">d</span>.<span class="ruby-identifier">owner</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">decoration</span>
499
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">decoration</span> = <span class="ruby-identifier">d</span>
500
+ <span class="ruby-keyword kw">end</span>
501
+ </pre>
502
+ </div>
503
+ </div>
504
+ </div>
505
+
506
+ <div id="method-M000170" class="method-detail">
507
+ <a name="M000170"></a>
508
+
509
+ <div class="method-heading">
510
+ <a href="#M000170" class="method-signature">
511
+ <span class="method-name">decoration</span><span class="method-args">()</span>
512
+ </a>
513
+ </div>
514
+
515
+ <div class="method-description">
516
+ <p>
517
+ Returns the first decoration from the component&#8217;s decoration chain,
518
+ or <tt>self</tt> if no decorations were specified for the component.
519
+ </p>
520
+ <p><a class="source-toggle" href="#"
521
+ onclick="toggleCode('M000170-source');return false;">[Source]</a></p>
522
+ <div class="method-source-code" id="M000170-source">
523
+ <pre>
524
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 128</span>
525
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">decoration</span>
526
+ <span class="ruby-ivar">@decoration</span>.<span class="ruby-identifier">value</span>
527
+ <span class="ruby-keyword kw">end</span>
528
+ </pre>
529
+ </div>
530
+ </div>
531
+ </div>
532
+
533
+ <div id="method-M000171" class="method-detail">
534
+ <a name="M000171"></a>
535
+
536
+ <div class="method-heading">
537
+ <a href="#M000171" class="method-signature">
538
+ <span class="method-name">decoration=</span><span class="method-args">(d)</span>
539
+ </a>
540
+ </div>
541
+
542
+ <div class="method-description">
543
+ <p>
544
+ Set the pointer to the first decoration to <tt>d</tt>.
545
+ </p>
546
+ <p><a class="source-toggle" href="#"
547
+ onclick="toggleCode('M000171-source');return false;">[Source]</a></p>
548
+ <div class="method-source-code" id="M000171-source">
549
+ <pre>
550
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 134</span>
551
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">decoration=</span>(<span class="ruby-identifier">d</span>)
552
+ <span class="ruby-ivar">@decoration</span>.<span class="ruby-identifier">value</span> = <span class="ruby-identifier">d</span>
553
+ <span class="ruby-keyword kw">end</span>
554
+ </pre>
555
+ </div>
556
+ </div>
557
+ </div>
558
+
559
+ <div id="method-M000172" class="method-detail">
560
+ <a name="M000172"></a>
561
+
562
+ <div class="method-heading">
563
+ <a href="#M000172" class="method-signature">
564
+ <span class="method-name">each_decoration</span><span class="method-args">( {|decoration| ...}</span>
565
+ </a>
566
+ </div>
567
+
568
+ <div class="method-description">
569
+ <p>
570
+ Iterates over all decorations (note that the component itself is excluded).
571
+ </p>
572
+ <p><a class="source-toggle" href="#"
573
+ onclick="toggleCode('M000172-source');return false;">[Source]</a></p>
574
+ <div class="method-source-code" id="M000172-source">
575
+ <pre>
576
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 140</span>
577
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">each_decoration</span> <span class="ruby-comment cmt"># :yields: decoration</span>
578
+ <span class="ruby-identifier">d</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">decoration</span>
579
+ <span class="ruby-identifier">loop</span> <span class="ruby-keyword kw">do</span>
580
+ <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">d</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">d</span>.<span class="ruby-identifier">nil?</span>
581
+ <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">d</span>
582
+ <span class="ruby-identifier">d</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">owner</span>
583
+ <span class="ruby-keyword kw">end</span>
584
+ <span class="ruby-keyword kw">end</span>
585
+ </pre>
586
+ </div>
587
+ </div>
588
+ </div>
589
+
590
+ <div id="method-M000174" class="method-detail">
591
+ <a name="M000174"></a>
592
+
593
+ <div class="method-heading">
594
+ <a href="#M000174" class="method-signature">
595
+ <span class="method-name">remove_decoration</span><span class="method-args">(d)</span>
596
+ </a>
597
+ </div>
598
+
599
+ <div class="method-description">
600
+ <p>
601
+ Remove decoration <tt>d</tt> from the decoration chain.
602
+ </p>
603
+ <p>
604
+ Returns the removed decoration or <tt>nil</tt> if it did not exist in the
605
+ decoration chain.
606
+ </p>
607
+ <p><a class="source-toggle" href="#"
608
+ onclick="toggleCode('M000174-source');return false;">[Source]</a></p>
609
+ <div class="method-source-code" id="M000174-source">
610
+ <pre>
611
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 161</span>
612
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_decoration</span>(<span class="ruby-identifier">d</span>)
613
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">d</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">decoration</span> <span class="ruby-comment cmt"># 'd' is in front</span>
614
+ <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">decoration</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">owner</span>
615
+ <span class="ruby-keyword kw">else</span>
616
+ <span class="ruby-identifier">last_decoration</span> = <span class="ruby-keyword kw">self</span>.<span class="ruby-identifier">decoration</span>
617
+ <span class="ruby-identifier">next_decoration</span> = <span class="ruby-keyword kw">nil</span>
618
+ <span class="ruby-identifier">loop</span> <span class="ruby-keyword kw">do</span>
619
+ <span class="ruby-keyword kw">return</span> <span class="ruby-keyword kw">nil</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">last_decoration</span> <span class="ruby-operator">==</span> <span class="ruby-keyword kw">self</span> <span class="ruby-keyword kw">or</span> <span class="ruby-identifier">last_decoration</span>.<span class="ruby-identifier">nil?</span>
620
+ <span class="ruby-identifier">next_decoration</span> = <span class="ruby-identifier">last_decoration</span>.<span class="ruby-identifier">owner</span>
621
+ <span class="ruby-keyword kw">break</span> <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">d</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">next_decoration</span>
622
+ <span class="ruby-identifier">last_decoration</span> = <span class="ruby-identifier">next_decoration</span>
623
+ <span class="ruby-keyword kw">end</span>
624
+ <span class="ruby-identifier">last_decoration</span>.<span class="ruby-identifier">owner</span> = <span class="ruby-identifier">d</span>.<span class="ruby-identifier">owner</span>
625
+ <span class="ruby-keyword kw">end</span>
626
+ <span class="ruby-identifier">d</span>.<span class="ruby-identifier">owner</span> = <span class="ruby-keyword kw">nil</span> <span class="ruby-comment cmt"># decoration 'd' no longer is an owner of anything!</span>
627
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">d</span>
628
+ <span class="ruby-keyword kw">end</span>
629
+ </pre>
630
+ </div>
631
+ </div>
632
+ </div>
633
+
634
+ <div id="method-M000175" class="method-detail">
635
+ <a name="M000175"></a>
636
+
637
+ <div class="method-heading">
638
+ <a href="#M000175" class="method-signature">
639
+ <span class="method-name">remove_decoration_if</span><span class="method-args">( {|decoration| ...}</span>
640
+ </a>
641
+ </div>
642
+
643
+ <div class="method-description">
644
+ <p>
645
+ Remove all decorations that match the block condition.
646
+ </p>
647
+ <p>
648
+ Example (removes all decorations of class <tt>HaloDecoration</tt>):
649
+ </p>
650
+ <pre>
651
+ remove_decoration_if {|d| d.class == HaloDecoration}
652
+ </pre>
653
+ <p><a class="source-toggle" href="#"
654
+ onclick="toggleCode('M000175-source');return false;">[Source]</a></p>
655
+ <div class="method-source-code" id="M000175-source">
656
+ <pre>
657
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 186</span>
658
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">remove_decoration_if</span> <span class="ruby-comment cmt"># :yields: decoration</span>
659
+ <span class="ruby-identifier">to_remove</span> = []
660
+ <span class="ruby-identifier">each_decoration</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">to_remove</span> <span class="ruby-operator">&lt;&lt;</span> <span class="ruby-identifier">d</span> <span class="ruby-keyword kw">if</span> <span class="ruby-keyword kw">yield</span> <span class="ruby-identifier">d</span>}
661
+ <span class="ruby-identifier">to_remove</span>.<span class="ruby-identifier">each</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">d</span><span class="ruby-operator">|</span> <span class="ruby-identifier">remove_decoration</span>(<span class="ruby-identifier">d</span>)}
662
+ <span class="ruby-keyword kw">end</span>
663
+ </pre>
664
+ </div>
665
+ </div>
666
+ </div>
667
+
668
+
669
+ </div>
670
+ <div id="section">
671
+ <h2 class="section-title"><a name="SEC00068">Backtrack</a></h2>
672
+ <div class="section-comment">
673
+
674
+ </div>
675
+
676
+
677
+
678
+
679
+
680
+
681
+
682
+
683
+ <!-- if method_list -->
684
+ <div id="methods">
685
+ <h3 class="section-bar">Public Instance methods</h3>
686
+
687
+ <div id="method-M000177" class="method-detail">
688
+ <a name="M000177"></a>
689
+
690
+ <div class="method-heading">
691
+ <a href="#M000177" class="method-signature">
692
+ <span class="method-name">backtrack_state</span><span class="method-args">(snapshot)</span>
693
+ </a>
694
+ </div>
695
+
696
+ <div class="method-description">
697
+ <p>
698
+ Take snapshots of objects that should correctly be backtracked.
699
+ </p>
700
+ <p>
701
+ Backtracking means that you can go back in time of the components&#8217;
702
+ state. Therefore it is neccessary to take snapshots of those objects that
703
+ want to participate in backtracking. Taking snapshots of the whole
704
+ component tree would be too expensive and unflexible. Note that methods
705
+ <em>take_snapshot</em> and <em>restore_snapshot</em> are called for those
706
+ objects to take the snapshot (they behave like <em>marshal_dump</em> and
707
+ <em>marshal_load</em>). Overwrite them if you want to define special
708
+ behaviour.
709
+ </p>
710
+ <p>
711
+ By default only <tt>@decoration</tt> is backtracked (which actually is a <a
712
+ href="ValueHolder.html">ValueHolder</a>, as only the pointer changes not
713
+ the decoration-object itself!).
714
+ </p>
715
+ <p>
716
+ For example if you dynamically add children to your component, you might
717
+ want to backtrack the children array. Therefore you simply pass it to the
718
+ <a href="Snapshot.html#M000069">Snapshot#add</a> method:
719
+ </p>
720
+ <pre>
721
+ def backtrack_state(snapshot)
722
+ super
723
+ snapshot.add(self.children)
724
+ end
725
+ </pre>
726
+ <p>
727
+ This will call <a href="../Array.html#M000003">Array#take_snapshot</a> to
728
+ take the snapshot for the children array. If at a later point in time a
729
+ snapshot is restored, <a
730
+ href="../Array.html#M000004">Array#restore_snapshot</a> will be called with
731
+ the return value of <a href="../Array.html#M000003">Array#take_snapshot</a>
732
+ as argument.
733
+ </p>
734
+ <dl>
735
+ <dt><tt>snapshot</tt></dt><dd>An object of class <a href="Snapshot.html">Snapshot</a>
736
+
737
+ </dd>
738
+ </dl>
739
+ <p><a class="source-toggle" href="#"
740
+ onclick="toggleCode('M000177-source');return false;">[Source]</a></p>
741
+ <div class="method-source-code" id="M000177-source">
742
+ <pre>
743
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 243</span>
744
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">backtrack_state</span>(<span class="ruby-identifier">snapshot</span>)
745
+ <span class="ruby-identifier">snapshot</span>.<span class="ruby-identifier">add</span>(<span class="ruby-ivar">@decoration</span>)
746
+ <span class="ruby-identifier">children</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword kw">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">child</span><span class="ruby-operator">|</span> <span class="ruby-identifier">child</span>.<span class="ruby-identifier">backtrack_state_chain</span>(<span class="ruby-identifier">snapshot</span>) <span class="ruby-keyword kw">end</span>
747
+ <span class="ruby-keyword kw">end</span>
748
+ </pre>
749
+ </div>
750
+ </div>
751
+ </div>
752
+
753
+ <div id="method-M000176" class="method-detail">
754
+ <a name="M000176"></a>
755
+
756
+ <div class="method-heading">
757
+ <a href="#M000176" class="method-signature">
758
+ <span class="method-name">backtrack_state_chain</span><span class="method-args">(snapshot)</span>
759
+ </a>
760
+ </div>
761
+
762
+ <div class="method-description">
763
+ <p>
764
+ Starts the backtrack-state phase for the decoration chain, by invoking
765
+ method <a href="Component.html#M000177">backtrack_state</a> of the first
766
+ decoration or the component itself if no decorations were specified.
767
+ </p>
768
+ <p>
769
+ See <a href="Component.html#M000177">backtrack_state</a> for details.
770
+ </p>
771
+ <dl>
772
+ <dt><tt>snapshot</tt></dt><dd>An object of class <a href="Snapshot.html">Snapshot</a>
773
+
774
+ </dd>
775
+ </dl>
776
+ <p><a class="source-toggle" href="#"
777
+ onclick="toggleCode('M000176-source');return false;">[Source]</a></p>
778
+ <div class="method-source-code" id="M000176-source">
779
+ <pre>
780
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 207</span>
781
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">backtrack_state_chain</span>(<span class="ruby-identifier">snapshot</span>)
782
+ <span class="ruby-identifier">decoration</span>.<span class="ruby-identifier">backtrack_state</span>(<span class="ruby-identifier">snapshot</span>)
783
+ <span class="ruby-keyword kw">end</span>
784
+ </pre>
785
+ </div>
786
+ </div>
787
+ </div>
788
+
789
+
790
+ </div>
791
+ <div id="section">
792
+ <h2 class="section-title"><a name="SEC00069">Call/Answer</a></h2>
793
+ <div class="section-comment">
794
+
795
+ </div>
796
+
797
+
798
+
799
+
800
+
801
+
802
+
803
+
804
+ <!-- if method_list -->
805
+ <div id="methods">
806
+ <h3 class="section-bar">Protected Instance methods</h3>
807
+
808
+ <div id="method-M000179" class="method-detail">
809
+ <a name="M000179"></a>
810
+
811
+ <div class="method-heading">
812
+ <a href="#M000179" class="method-signature">
813
+ <span class="method-name">answer</span><span class="method-args">(*args)</span>
814
+ </a>
815
+ </div>
816
+
817
+ <div class="method-description">
818
+ <p>
819
+ Return from a called component.
820
+ </p>
821
+ <p>
822
+ NOTE that <a href="Component.html#M000179">answer</a> never returns.
823
+ </p>
824
+ <p>
825
+ See <a href="Component.html#M000178">call</a> for a detailed description of
826
+ the call/answer mechanism.
827
+ </p>
828
+ <p><a class="source-toggle" href="#"
829
+ onclick="toggleCode('M000179-source');return false;">[Source]</a></p>
830
+ <div class="method-source-code" id="M000179-source">
831
+ <pre>
832
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 310</span>
833
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">answer</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
834
+ <span class="ruby-identifier">throw</span> <span class="ruby-identifier">:wee_answer</span>, <span class="ruby-identifier">args</span>
835
+ <span class="ruby-keyword kw">end</span>
836
+ </pre>
837
+ </div>
838
+ </div>
839
+ </div>
840
+
841
+ <div id="method-M000178" class="method-detail">
842
+ <a name="M000178"></a>
843
+
844
+ <div class="method-heading">
845
+ <a href="#M000178" class="method-signature">
846
+ <span class="method-name">call</span><span class="method-args">(component, return_callback=:use_continuation)</span>
847
+ </a>
848
+ </div>
849
+
850
+ <div class="method-description">
851
+ <p>
852
+ Call another component. The calling component is neither rendered nor are
853
+ it&#8217;s callbacks processed until the called component answers using
854
+ method <a href="Component.html#M000179">answer</a>.
855
+ </p>
856
+ <dl>
857
+ <dt><tt>component</tt></dt><dd>The component to be called.
858
+
859
+ </dd>
860
+ </dl>
861
+ <p>
862
+ <b>How it works</b>
863
+ </p>
864
+ <p>
865
+ At first a continuation is created. The component to be called is then
866
+ wrapped with an <a href="AnswerDecoration.html">AnswerDecoration</a> and
867
+ the continuation is assigned to it&#8217;s <tt>on_answer</tt> attribute.
868
+ Then a <a href="Delegate.html">Delegate</a> decoration is added to the
869
+ calling component (self), which delegates to the component to be called
870
+ (<tt>component</tt>). Then we unwind the calling stack back to the <a
871
+ href="Session.html">Session</a> by throwing <em>:wee_back_to_session</em>.
872
+ This means, that there is only ever one action callback invoked per
873
+ request. When at a later point in time the called component invokes <a
874
+ href="Component.html#M000179">answer</a>, this will throw a
875
+ <em>:wee_answer</em> exception which is catched in the <a
876
+ href="AnswerDecoration.html">AnswerDecoration</a>. The <a
877
+ href="AnswerDecoration.html">AnswerDecoration</a> then jumps back to the
878
+ continuation we created at the beginning, and finally method <a
879
+ href="Component.html#M000178">call</a> returns.
880
+ </p>
881
+ <p>
882
+ Note that <a href="Component.html#M000178">call</a> returns to an
883
+ &quot;old&quot; stack-frame from a previous request. That is why we throw
884
+ <em>:wee_back_to_session</em> after invoking an action callback, and
885
+ that&#8217;s why only ever one is invoked. We could remove this limitation
886
+ without problems, but then there would be a difference between those action
887
+ callbacks that call other components and those that do not.
888
+ </p>
889
+ <p><a class="source-toggle" href="#"
890
+ onclick="toggleCode('M000178-source');return false;">[Source]</a></p>
891
+ <div class="method-source-code" id="M000178-source">
892
+ <pre>
893
+ <span class="ruby-comment cmt"># File lib/wee/core/component.rb, line 281</span>
894
+ <span class="ruby-keyword kw">def</span> <span class="ruby-identifier">call</span>(<span class="ruby-identifier">component</span>, <span class="ruby-identifier">return_callback</span>=<span class="ruby-identifier">:use_continuation</span>)
895
+ <span class="ruby-identifier">add_decoration</span>(<span class="ruby-identifier">delegate</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">Delegate</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">component</span>))
896
+ <span class="ruby-identifier">component</span>.<span class="ruby-identifier">add_decoration</span>(<span class="ruby-identifier">answer</span> = <span class="ruby-constant">Wee</span><span class="ruby-operator">::</span><span class="ruby-constant">AnswerDecoration</span>.<span class="ruby-identifier">new</span>)
897
+
898
+ <span class="ruby-keyword kw">if</span> <span class="ruby-identifier">return_callback</span> <span class="ruby-operator">==</span> <span class="ruby-identifier">:use_continuation</span>
899
+ <span class="ruby-identifier">result</span> = <span class="ruby-identifier">callcc</span> {<span class="ruby-operator">|</span><span class="ruby-identifier">cc</span><span class="ruby-operator">|</span>
900
+ <span class="ruby-identifier">answer</span>.<span class="ruby-identifier">on_answer</span> = <span class="ruby-identifier">cc</span>
901
+ <span class="ruby-identifier">throw</span> <span class="ruby-identifier">:wee_back_to_session</span>
902
+ }
903
+ <span class="ruby-identifier">remove_decoration</span>(<span class="ruby-identifier">delegate</span>)
904
+ <span class="ruby-identifier">component</span>.<span class="ruby-identifier">remove_decoration</span>(<span class="ruby-identifier">answer</span>)
905
+ <span class="ruby-keyword kw">return</span> <span class="ruby-identifier">result</span>
906
+ <span class="ruby-keyword kw">else</span>
907
+ <span class="ruby-comment cmt"># TODO: make this marshallable! </span>
908
+ <span class="ruby-identifier">answer</span>.<span class="ruby-identifier">on_answer</span> = <span class="ruby-identifier">proc</span> {<span class="ruby-operator">|</span><span class="ruby-operator">*</span><span class="ruby-identifier">args</span><span class="ruby-operator">|</span>
909
+ <span class="ruby-identifier">remove_decoration</span>(<span class="ruby-identifier">delegate</span>)
910
+ <span class="ruby-identifier">component</span>.<span class="ruby-identifier">remove_decoration</span>(<span class="ruby-identifier">answer</span>)
911
+ <span class="ruby-identifier">return_callback</span>.<span class="ruby-identifier">call</span>(<span class="ruby-operator">*</span><span class="ruby-identifier">args</span>)
912
+ }
913
+ <span class="ruby-identifier">throw</span> <span class="ruby-identifier">:wee_back_to_session</span>
914
+ <span class="ruby-keyword kw">end</span>
915
+ <span class="ruby-keyword kw">end</span>
916
+ </pre>
917
+ </div>
918
+ </div>
919
+ </div>
920
+
921
+
922
+ </div>
923
+
924
+
925
+ </div>
926
+
927
+
928
+ <div id="validator-badges">
929
+ <p><small><a href="http://validator.w3.org/check/referer">[Validate]</a></small></p>
930
+ </div>
931
+
932
+ </body>
933
+ </html>