wee 0.10.0 → 2.0.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.
- data/README.rdoc +127 -0
- data/Rakefile +11 -32
- data/doc/rdoc/classes/Array.html +28 -24
- data/doc/rdoc/classes/Hash.html +28 -24
- data/doc/rdoc/classes/Object.html +37 -84
- data/doc/rdoc/classes/String.html +89 -21
- data/doc/rdoc/classes/Struct.html +32 -82
- data/doc/rdoc/classes/Wee.html +285 -86
- data/doc/rdoc/classes/Wee/AnswerDecoration.html +111 -48
- data/doc/rdoc/classes/Wee/{Context.html → AnswerDecoration/Answer.html} +61 -51
- data/doc/rdoc/classes/Wee/Application.html +161 -322
- data/doc/rdoc/classes/Wee/Application/SessionCache.html +162 -0
- data/doc/rdoc/classes/Wee/Brush.html +147 -62
- data/doc/rdoc/classes/{Enumerable.html → Wee/Brush/ActionInputTag.html} +68 -41
- data/doc/rdoc/classes/Wee/Brush/AnchorTag.html +150 -100
- data/doc/rdoc/classes/Wee/Brush/CheckboxTag.html +132 -46
- data/doc/rdoc/classes/Wee/Brush/FileUploadTag.html +63 -41
- data/doc/rdoc/classes/Wee/Brush/FormTag.html +184 -78
- data/doc/rdoc/classes/Wee/Brush/GenericEncodedTextBrush.html +48 -65
- data/doc/rdoc/classes/Wee/Brush/GenericSingleTagBrush.html +83 -37
- data/doc/rdoc/classes/Wee/Brush/GenericTagBrush.html +334 -310
- data/doc/rdoc/classes/Wee/Brush/GenericTextBrush.html +74 -54
- data/doc/rdoc/classes/Wee/Brush/HiddenInputTag.html +58 -43
- data/doc/rdoc/classes/Wee/Brush/ImageButtonTag.html +64 -74
- data/doc/rdoc/classes/Wee/Brush/ImageTag.html +109 -86
- data/doc/rdoc/classes/Wee/Brush/InputTag.html +205 -45
- data/doc/rdoc/classes/Wee/Brush/JavascriptTag.html +96 -34
- data/doc/rdoc/classes/Wee/Brush/Page.html +129 -67
- data/doc/rdoc/classes/Wee/{Utils/LRUCache.html → Brush/PasswordInputTag.html} +65 -38
- data/doc/rdoc/classes/Wee/Brush/RadioButtonTag.html +132 -78
- data/doc/rdoc/classes/Wee/Brush/{RadioButtonTag/RadioGroup.html → RadioGroup.html} +91 -53
- data/doc/rdoc/classes/Wee/Brush/SelectListTag.html +301 -127
- data/doc/rdoc/classes/Wee/Brush/SelectOptionTag.html +96 -33
- data/doc/rdoc/classes/Wee/Brush/SubmitButtonTag.html +59 -44
- data/doc/rdoc/classes/Wee/Brush/TableDataTag.html +94 -57
- data/doc/rdoc/classes/Wee/Brush/TableHeaderTag.html +96 -33
- data/doc/rdoc/classes/Wee/Brush/TableRowTag.html +181 -121
- data/doc/rdoc/classes/Wee/Brush/TableTag.html +94 -32
- data/doc/rdoc/classes/Wee/Brush/TextAreaTag.html +257 -71
- data/doc/rdoc/classes/Wee/Brush/TextInputTag.html +58 -43
- data/doc/rdoc/classes/Wee/CallAnswerMixin.html +289 -0
- data/doc/rdoc/classes/Wee/CallbackMixin.html +233 -0
- data/doc/rdoc/classes/Wee/CallbackRegistry.html +179 -155
- data/doc/rdoc/classes/Wee/Callbacks.html +262 -0
- data/doc/rdoc/classes/Wee/Component.html +228 -779
- data/doc/rdoc/classes/Wee/Decoration.html +144 -159
- data/doc/rdoc/classes/Wee/DecorationMixin.html +340 -0
- data/doc/rdoc/classes/Wee/Delegate.html +119 -76
- data/doc/rdoc/classes/Wee/DupReplaceSnapshotMixin.html +64 -47
- data/doc/rdoc/classes/Wee/ErrorResponse.html +59 -62
- data/doc/rdoc/classes/Wee/FormDecoration.html +51 -37
- data/doc/rdoc/classes/Wee/GenericResponse.html +60 -35
- data/doc/rdoc/classes/Wee/HtmlCanvas.html +1000 -602
- data/doc/rdoc/classes/Wee/HtmlDocument.html +288 -0
- data/doc/rdoc/classes/Wee/HtmlWriter.html +227 -126
- data/doc/rdoc/classes/Wee/IdGenerator.html +60 -31
- data/doc/rdoc/classes/Wee/IdGenerator/Secure.html +282 -0
- data/doc/rdoc/classes/Wee/{SimpleIdGenerator.html → IdGenerator/Sequential.html} +76 -49
- data/doc/rdoc/classes/Wee/JQuery.html +221 -0
- data/doc/rdoc/classes/Wee/LRUCache.html +514 -0
- data/doc/rdoc/classes/Wee/LRUCache/Item.html +158 -0
- data/doc/rdoc/classes/Wee/ObjectSnapshotMixin.html +187 -0
- data/doc/rdoc/classes/Wee/PageDecoration.html +88 -59
- data/doc/rdoc/classes/Wee/Presenter.html +124 -704
- data/doc/rdoc/classes/Wee/RedirectResponse.html +64 -33
- data/doc/rdoc/classes/Wee/RefreshResponse.html +59 -44
- data/doc/rdoc/classes/Wee/Renderer.html +234 -54
- data/doc/rdoc/classes/Wee/Request.html +151 -286
- data/doc/rdoc/classes/Wee/Response.html +29 -212
- data/doc/rdoc/classes/Wee/Session.html +585 -360
- data/doc/rdoc/classes/Wee/{StateHolder.html → Session/AbortCallbackProcessing.html} +67 -40
- data/doc/rdoc/classes/Wee/Session/MutexSerializer.html +166 -0
- data/doc/rdoc/classes/{Cache/Strategy/LFU/Item.html → Wee/Session/Page.html} +26 -27
- data/doc/rdoc/classes/Wee/Session/ThreadSerializer.html +219 -0
- data/doc/rdoc/classes/Wee/State.html +307 -0
- data/doc/rdoc/classes/{Cache/Strategy/LRU/Item.html → Wee/State/Snapshot.html} +26 -27
- data/doc/rdoc/classes/{Cache/Strategy/Unbounded/Item.html → Wee/State/SnapshotIVars.html} +26 -27
- data/doc/rdoc/classes/Wee/StructSnapshotMixin.html +183 -0
- data/doc/rdoc/classes/Wee/WrapperDecoration.html +101 -35
- data/doc/rdoc/created.rid +1 -1
- data/doc/rdoc/files/README_rdoc.html +243 -0
- data/doc/rdoc/files/lib/wee/application_rb.html +22 -30
- data/doc/rdoc/files/lib/wee/{page_rb.html → call_answer_rb.html} +14 -25
- data/doc/rdoc/files/lib/wee/callback_rb.html +12 -29
- data/doc/rdoc/files/lib/wee/component_rb.html +22 -27
- data/doc/rdoc/files/lib/wee/decoration_rb.html +19 -20
- data/doc/rdoc/files/lib/wee/{idgen_rb.html → html_brushes_rb.html} +14 -25
- data/doc/rdoc/files/lib/wee/html_canvas_rb.html +15 -23
- data/doc/rdoc/files/lib/wee/{abstractsession_rb.html → html_document_rb.html} +17 -25
- data/doc/rdoc/files/lib/wee/html_writer_rb.html +15 -23
- data/doc/rdoc/files/lib/wee/{webrick_rb.html → id_generator_rb.html} +19 -25
- data/doc/rdoc/files/lib/wee/{core/page_rb.html → jquery/jquery_rb.html} +14 -25
- data/doc/rdoc/files/lib/wee/{state_registry_rb.html → jquery_rb.html} +17 -27
- data/doc/rdoc/files/lib/{cache/cache_rb.html → wee/lru_cache_rb.html} +14 -25
- data/doc/rdoc/files/lib/wee/presenter_rb.html +12 -34
- data/doc/rdoc/files/lib/wee/{holder_rb.html → renderer_rb.html} +14 -25
- data/doc/rdoc/files/lib/wee/request_rb.html +18 -32
- data/doc/rdoc/files/lib/wee/response_rb.html +17 -24
- data/doc/rdoc/files/lib/wee/session_rb.html +21 -23
- data/doc/rdoc/files/lib/wee/state_rb.html +90 -0
- data/doc/rdoc/files/lib/wee_rb.html +48 -40
- data/doc/rdoc/fr_class_index.html +111 -75
- data/doc/rdoc/fr_file_index.html +46 -76
- data/doc/rdoc/fr_method_index.html +473 -480
- data/doc/rdoc/index.html +6 -9
- data/doc/rdoc/rdoc-style.css +210 -119
- data/examples/ObjectSpaceBrowser.rb +33 -23
- data/examples/ajax.rb +71 -0
- data/examples/continuations.rb +28 -0
- data/examples/demo.rb +92 -36
- data/examples/demo/calculator.rb +63 -0
- data/examples/demo/calendar.rb +42 -55
- data/examples/demo/counter.rb +38 -0
- data/{lib/wee/examples → examples/demo}/editable_counter.rb +11 -6
- data/examples/demo/example.rb +28 -24
- data/examples/demo/file_upload.rb +19 -0
- data/{lib/wee/components → examples/demo}/messagebox.rb +3 -3
- data/examples/demo/radio.rb +33 -0
- data/{lib/wee/examples → examples/demo}/window.rb +15 -10
- data/examples/hw.rb +3 -4
- data/{lib/wee/components → examples}/pager.rb +14 -14
- data/lib/wee.rb +48 -25
- data/lib/wee/application.rb +69 -131
- data/lib/wee/call_answer.rb +118 -0
- data/lib/wee/callback.rb +88 -0
- data/lib/wee/component.rb +141 -0
- data/lib/wee/decoration.rb +242 -0
- data/lib/wee/html_brushes.rb +725 -0
- data/lib/wee/html_canvas.rb +241 -0
- data/lib/wee/html_document.rb +45 -0
- data/lib/wee/html_writer.rb +71 -0
- data/lib/wee/id_generator.rb +70 -0
- data/lib/wee/jquery.rb +1 -0
- data/lib/wee/jquery/jquery.rb +17 -0
- data/lib/wee/jquery/public/jquery-1.3.2.min.js +19 -0
- data/lib/wee/jquery/public/wee-jquery.js +19 -0
- data/lib/wee/lru_cache.rb +89 -0
- data/lib/wee/presenter.rb +43 -0
- data/lib/wee/renderer.rb +65 -0
- data/lib/wee/request.rb +37 -113
- data/lib/wee/response.rb +43 -70
- data/lib/wee/session.rb +304 -113
- data/lib/wee/state.rb +85 -0
- data/test/component_spec.rb +17 -0
- data/wee.gemspec +4 -3
- metadata +249 -452
- data/ChangeLog +0 -657
- data/INSTALL +0 -17
- data/README +0 -272
- data/TODO +0 -142
- data/benchmark/Centrino1300/result.2000.counter.action +0 -45
- data/benchmark/Centrino1300/result.2000.counter.render +0 -43
- data/benchmark/Centrino1300/result.2000.filehandler +0 -43
- data/benchmark/Centrino600/result.2000.counter.action +0 -47
- data/benchmark/Centrino600/result.2000.counter.render +0 -45
- data/benchmark/Centrino600/result.2000.filehandler +0 -43
- data/benchmark/Makefile +0 -53
- data/benchmark/counter.rb +0 -77
- data/benchmark/filehandler.rb +0 -6
- data/benchmark/report_req.rb +0 -12
- data/bin/wee +0 -100
- data/doc/rdoc/classes/ActionView.html +0 -107
- data/doc/rdoc/classes/ActionView/Base.html +0 -133
- data/doc/rdoc/classes/Cache.html +0 -126
- data/doc/rdoc/classes/Cache/StorageCache.html +0 -320
- data/doc/rdoc/classes/Cache/Strategy.html +0 -128
- data/doc/rdoc/classes/Cache/Strategy/CapacityBounded.html +0 -269
- data/doc/rdoc/classes/Cache/Strategy/LFU.html +0 -238
- data/doc/rdoc/classes/Cache/Strategy/LRU.html +0 -238
- data/doc/rdoc/classes/Cache/Strategy/Unbounded.html +0 -225
- data/doc/rdoc/classes/LiteralMethod.html +0 -196
- data/doc/rdoc/classes/Main.html +0 -289
- data/doc/rdoc/classes/OgApplication.html +0 -126
- data/doc/rdoc/classes/OgScaffolder.html +0 -827
- data/doc/rdoc/classes/OgScaffolder/Editor.html +0 -565
- data/doc/rdoc/classes/OgSession.html +0 -172
- data/doc/rdoc/classes/Recipe.html +0 -113
- data/doc/rdoc/classes/Wee/AbstractSession.html +0 -502
- data/doc/rdoc/classes/Wee/Brush/ActionCallbackMixin.html +0 -148
- data/doc/rdoc/classes/Wee/Brush/ActionMixin.html +0 -146
- data/doc/rdoc/classes/Wee/Brush/ActionURLCallbackMixin.html +0 -154
- data/doc/rdoc/classes/Wee/Brush/AssignMixin.html +0 -141
- data/doc/rdoc/classes/Wee/Brush/CallbackMixin.html +0 -141
- data/doc/rdoc/classes/Wee/Brush/InputCallbackMixin.html +0 -148
- data/doc/rdoc/classes/Wee/Brush/SelectListTag/SelectListCallback.html +0 -158
- data/doc/rdoc/classes/Wee/Brush/ToCallback.html +0 -146
- data/doc/rdoc/classes/Wee/Callback.html +0 -231
- data/doc/rdoc/classes/Wee/CallbackStream.html +0 -227
- data/doc/rdoc/classes/Wee/Canvas.html +0 -235
- data/doc/rdoc/classes/Wee/CanvasMixin.html +0 -225
- data/doc/rdoc/classes/Wee/Component/OnAnswer.html +0 -153
- data/doc/rdoc/classes/Wee/ComponentDispatcher.html +0 -289
- data/doc/rdoc/classes/Wee/ComponentRunner.html +0 -321
- data/doc/rdoc/classes/Wee/ErrorPage.html +0 -175
- data/doc/rdoc/classes/Wee/Examples.html +0 -114
- data/doc/rdoc/classes/Wee/Examples/Calculator.html +0 -319
- data/doc/rdoc/classes/Wee/Examples/Counter.html +0 -289
- data/doc/rdoc/classes/Wee/Examples/EditableCounter.html +0 -210
- data/doc/rdoc/classes/Wee/Examples/Window.html +0 -346
- data/doc/rdoc/classes/Wee/FastCGIAdaptor.html +0 -227
- data/doc/rdoc/classes/Wee/Helper.html +0 -148
- data/doc/rdoc/classes/Wee/HtmlCanvasRenderer.html +0 -1230
- data/doc/rdoc/classes/Wee/LiteralMethodCallback.html +0 -198
- data/doc/rdoc/classes/Wee/LoginDecoration.html +0 -261
- data/doc/rdoc/classes/Wee/Md5IdGenerator.html +0 -181
- data/doc/rdoc/classes/Wee/MessageBox.html +0 -180
- data/doc/rdoc/classes/Wee/MethodCallback.html +0 -193
- data/doc/rdoc/classes/Wee/Nitro.html +0 -114
- data/doc/rdoc/classes/Wee/Nitro/ControllerClassMixin.html +0 -192
- data/doc/rdoc/classes/Wee/Nitro/ControllerMixin.html +0 -345
- data/doc/rdoc/classes/Wee/Nitro/FormTag.html +0 -155
- data/doc/rdoc/classes/Wee/Nitro/HtmlCanvasRenderer.html +0 -178
- data/doc/rdoc/classes/Wee/Page.html +0 -115
- data/doc/rdoc/classes/Wee/PagelessApplication.html +0 -154
- data/doc/rdoc/classes/Wee/PagelessComponentDriver.html +0 -296
- data/doc/rdoc/classes/Wee/PagelessRequest.html +0 -208
- data/doc/rdoc/classes/Wee/PagelessSession.html +0 -359
- data/doc/rdoc/classes/Wee/Pager.html +0 -534
- data/doc/rdoc/classes/Wee/Rails.html +0 -114
- data/doc/rdoc/classes/Wee/Rails/ControllerClassMixin.html +0 -192
- data/doc/rdoc/classes/Wee/Rails/ControllerMixin.html +0 -342
- data/doc/rdoc/classes/Wee/Rails/FormTag.html +0 -155
- data/doc/rdoc/classes/Wee/Rails/HtmlCanvasRenderer.html +0 -177
- data/doc/rdoc/classes/Wee/RenderingContext.html +0 -283
- data/doc/rdoc/classes/Wee/RequestHandler.html +0 -341
- data/doc/rdoc/classes/Wee/Snapshot.html +0 -211
- data/doc/rdoc/classes/Wee/StateRegistry.html +0 -434
- data/doc/rdoc/classes/Wee/StateRegistry/Snapshot.html +0 -320
- data/doc/rdoc/classes/Wee/StateRegistry/WithObject.html +0 -153
- data/doc/rdoc/classes/Wee/Utils.html +0 -300
- data/doc/rdoc/classes/Wee/ValueHolder.html +0 -220
- data/doc/rdoc/classes/Wee/WEBrickAdaptor.html +0 -368
- data/doc/rdoc/files/INSTALL.html +0 -130
- data/doc/rdoc/files/README.html +0 -471
- data/doc/rdoc/files/lib/wee/adaptors/fastcgi_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/adaptors/nitro_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/adaptors/rails_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/adaptors/webrick_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/component_ext_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/components/component_dispatcher_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/components/form_decoration_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/components/login_decoration_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/components/messagebox_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/components/page_decoration_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/components/pager_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/components/wrapper_decoration_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/components_rb.html +0 -114
- data/doc/rdoc/files/lib/wee/context_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/continuation/core/component_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/continuation/session_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/continuation_rb.html +0 -116
- data/doc/rdoc/files/lib/wee/core/callback_rb.html +0 -115
- data/doc/rdoc/files/lib/wee/core/component_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/core/componentrunner_rb.html +0 -110
- data/doc/rdoc/files/lib/wee/core/context_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/core/decoration_rb.html +0 -133
- data/doc/rdoc/files/lib/wee/core/idgen_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/core/presenter_rb.html +0 -112
- data/doc/rdoc/files/lib/wee/core/renderer_rb.html +0 -107
- data/doc/rdoc/files/lib/wee/core/snapshot_rb.html +0 -113
- data/doc/rdoc/files/lib/wee/core/valueholder_rb.html +0 -110
- data/doc/rdoc/files/lib/wee/core_ext_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/core_rb.html +0 -124
- data/doc/rdoc/files/lib/wee/databases/og/application_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/databases/og/old_scaffolder_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/databases/og/scaffolder_rb.html +0 -115
- data/doc/rdoc/files/lib/wee/databases/og/session_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/databases/og_rb.html +0 -111
- data/doc/rdoc/files/lib/wee/examples/calculator_rb.html +0 -107
- data/doc/rdoc/files/lib/wee/examples/counter_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/examples/editable_counter_rb.html +0 -114
- data/doc/rdoc/files/lib/wee/examples/window_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/idgen/md5_rb.html +0 -115
- data/doc/rdoc/files/lib/wee/idgen/simple_rb.html +0 -107
- data/doc/rdoc/files/lib/wee/pageless/application_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/pageless/request_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/pageless/session_rb.html +0 -109
- data/doc/rdoc/files/lib/wee/pageless_rb.html +0 -110
- data/doc/rdoc/files/lib/wee/renderer/html/brushes_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/renderer/html/canvas_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/renderer/html/writer_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/rendering/html/brushes_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/rendering/html/canvas_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/rendering/html/writer_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/requesthandler_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/skeleton/og/components/main_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/skeleton/og/conf/db_rb.html +0 -114
- data/doc/rdoc/files/lib/wee/skeleton/og/models/recipe_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/skeleton/og/run_rb.html +0 -115
- data/doc/rdoc/files/lib/wee/skeleton/simple/components/main_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/skeleton/simple/run_rb.html +0 -111
- data/doc/rdoc/files/lib/wee/snapshot_ext_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/snapshot_rb.html +0 -107
- data/doc/rdoc/files/lib/wee/stuff_rb.html +0 -144
- data/doc/rdoc/files/lib/wee/template_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/utils/autoreload_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/utils/cache_rb.html +0 -108
- data/doc/rdoc/files/lib/wee/utils/helper_rb.html +0 -101
- data/doc/rdoc/files/lib/wee/utils_rb.html +0 -110
- data/examples/ajax/ajax.js +0 -444
- data/examples/ajax/ajax.rb +0 -31
- data/examples/cc.rb +0 -74
- data/examples/dispatcher.rb +0 -37
- data/examples/draw.rb +0 -94
- data/examples/live-update.rb +0 -45
- data/examples/nitro/run.rb +0 -42
- data/examples/og-test.rb +0 -60
- data/examples/radio.rb +0 -44
- data/examples/test.rb +0 -39
- data/install.rb +0 -14
- data/lib/cache/cache.rb +0 -167
- data/lib/wee/abstractsession.rb +0 -96
- data/lib/wee/adaptors/fastcgi.rb +0 -76
- data/lib/wee/adaptors/nitro.rb +0 -155
- data/lib/wee/adaptors/rails.rb +0 -154
- data/lib/wee/adaptors/webrick.rb +0 -89
- data/lib/wee/components.rb +0 -7
- data/lib/wee/components/component_dispatcher.rb +0 -46
- data/lib/wee/components/form_decoration.rb +0 -7
- data/lib/wee/components/login_decoration.rb +0 -35
- data/lib/wee/components/page_decoration.rb +0 -14
- data/lib/wee/components/wrapper_decoration.rb +0 -7
- data/lib/wee/continuation.rb +0 -5
- data/lib/wee/continuation/core/component.rb +0 -56
- data/lib/wee/continuation/session.rb +0 -64
- data/lib/wee/core.rb +0 -16
- data/lib/wee/core/callback.rb +0 -121
- data/lib/wee/core/component.rb +0 -356
- data/lib/wee/core/componentrunner.rb +0 -73
- data/lib/wee/core/context.rb +0 -27
- data/lib/wee/core/decoration.rb +0 -138
- data/lib/wee/core/idgen.rb +0 -5
- data/lib/wee/core/page.rb +0 -1
- data/lib/wee/core/presenter.rb +0 -100
- data/lib/wee/core/renderer.rb +0 -23
- data/lib/wee/core/snapshot.rb +0 -21
- data/lib/wee/core/valueholder.rb +0 -19
- data/lib/wee/core_ext.rb +0 -122
- data/lib/wee/databases/og.rb +0 -4
- data/lib/wee/databases/og/application.rb +0 -3
- data/lib/wee/databases/og/old_scaffolder.rb +0 -98
- data/lib/wee/databases/og/scaffolder.rb +0 -255
- data/lib/wee/databases/og/session.rb +0 -9
- data/lib/wee/examples/calculator.rb +0 -70
- data/lib/wee/examples/counter.rb +0 -33
- data/lib/wee/idgen/md5.rb +0 -21
- data/lib/wee/idgen/sequential.rb +0 -11
- data/lib/wee/pageless.rb +0 -3
- data/lib/wee/pageless/application.rb +0 -13
- data/lib/wee/pageless/request.rb +0 -27
- data/lib/wee/pageless/session.rb +0 -74
- data/lib/wee/renderer/html/brushes.rb +0 -667
- data/lib/wee/renderer/html/canvas.rb +0 -265
- data/lib/wee/renderer/html/writer.rb +0 -80
- data/lib/wee/requesthandler.rb +0 -81
- data/lib/wee/skeleton/og/README +0 -38
- data/lib/wee/skeleton/og/components/main.rb +0 -20
- data/lib/wee/skeleton/og/conf/db.rb +0 -8
- data/lib/wee/skeleton/og/models/recipe.rb +0 -5
- data/lib/wee/skeleton/og/run.rb +0 -23
- data/lib/wee/skeleton/simple/README +0 -32
- data/lib/wee/skeleton/simple/components/main.rb +0 -25
- data/lib/wee/skeleton/simple/run.rb +0 -12
- data/lib/wee/snapshot_ext.rb +0 -41
- data/lib/wee/template.rb +0 -42
- data/lib/wee/utils.rb +0 -5
- data/lib/wee/utils/autoreload.rb +0 -56
- data/lib/wee/utils/cache.rb +0 -7
- data/lib/wee/utils/helper.rb +0 -51
data/lib/wee/core.rb
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
# There are no dependencies to outer classes!
|
|
2
|
-
|
|
3
|
-
module Wee; end
|
|
4
|
-
|
|
5
|
-
require 'wee/core/valueholder'
|
|
6
|
-
require 'wee/core/snapshot'
|
|
7
|
-
require 'wee/core/callback'
|
|
8
|
-
require 'wee/core/page'
|
|
9
|
-
require 'wee/core/context'
|
|
10
|
-
require 'wee/core/idgen'
|
|
11
|
-
require 'wee/core/renderer'
|
|
12
|
-
require 'wee/core/componentrunner'
|
|
13
|
-
|
|
14
|
-
require 'wee/core/presenter'
|
|
15
|
-
require 'wee/core/decoration'
|
|
16
|
-
require 'wee/core/component'
|
data/lib/wee/core/callback.rb
DELETED
|
@@ -1,121 +0,0 @@
|
|
|
1
|
-
# The callback registry is the central datastructure where all components of a
|
|
2
|
-
# session register their callbacks.
|
|
3
|
-
#
|
|
4
|
-
# The format of the internal datastructure is:
|
|
5
|
-
#
|
|
6
|
-
# @callbacks[type][callback_id] => callback
|
|
7
|
-
# @obj_to_id_map[type][object] => [id*]
|
|
8
|
-
|
|
9
|
-
class Wee::CallbackRegistry
|
|
10
|
-
|
|
11
|
-
def initialize(id_generator)
|
|
12
|
-
@idgen = id_generator
|
|
13
|
-
@callbacks = Hash.new
|
|
14
|
-
@obj_to_id_map = Hash.new
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# Register +callback+ for +object+ under +type+ and return a unique callback id.
|
|
18
|
-
|
|
19
|
-
def register_for(object, type, callback)
|
|
20
|
-
register_named_for(object, type, callback, @idgen.next)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# Register +callback+ for +object+ under +type+ with the id +named_id+.
|
|
24
|
-
|
|
25
|
-
def register_named_for(object, type, callback, named_id)
|
|
26
|
-
cid = named_id.to_s
|
|
27
|
-
c = (@callbacks[type] ||= Hash.new)
|
|
28
|
-
o = (@obj_to_id_map[type] ||= Hash.new)
|
|
29
|
-
raise "duplicate callback id" if c.has_key?(cid)
|
|
30
|
-
c[cid] = callback
|
|
31
|
-
(o[object] ||= []) << cid
|
|
32
|
-
return cid
|
|
33
|
-
end
|
|
34
|
-
|
|
35
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
36
|
-
# :section: Friend methods for Wee::CallbackStream
|
|
37
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
38
|
-
|
|
39
|
-
def get_ids_for(object, type)
|
|
40
|
-
if o = @obj_to_id_map[type]
|
|
41
|
-
o[object] || []
|
|
42
|
-
else
|
|
43
|
-
[]
|
|
44
|
-
end
|
|
45
|
-
end
|
|
46
|
-
|
|
47
|
-
def get_callback_for(id, type)
|
|
48
|
-
if c = @callbacks[type]
|
|
49
|
-
c[id]
|
|
50
|
-
else
|
|
51
|
-
raise
|
|
52
|
-
end
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
def all_of_type(type)
|
|
56
|
-
if c = @callbacks[type]
|
|
57
|
-
c
|
|
58
|
-
else
|
|
59
|
-
[]
|
|
60
|
-
end
|
|
61
|
-
end
|
|
62
|
-
|
|
63
|
-
end
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
# The intersection of registered callbacks and those that occured.
|
|
67
|
-
|
|
68
|
-
class Wee::CallbackStream
|
|
69
|
-
|
|
70
|
-
#
|
|
71
|
-
# [<tt>callbacks</tt>]
|
|
72
|
-
# A Wee::CallbackRegistry
|
|
73
|
-
#
|
|
74
|
-
# [<tt>ids_and_values</tt>]
|
|
75
|
-
# A hash that contains all callback ids together with their values that
|
|
76
|
-
# occurend in a request, e.g. { id => value }.
|
|
77
|
-
|
|
78
|
-
def initialize(callbacks, ids_and_values)
|
|
79
|
-
@callbacks = callbacks
|
|
80
|
-
@ids_and_values = ids_and_values
|
|
81
|
-
@ids = @ids_and_values.keys
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def with_callbacks_for(object, type)
|
|
85
|
-
matching_ids = @callbacks.get_ids_for(object, type) & @ids
|
|
86
|
-
matching_ids.each do |id|
|
|
87
|
-
yield @callbacks.get_callback_for(id, type), @ids_and_values[id]
|
|
88
|
-
end
|
|
89
|
-
@ids -= matching_ids
|
|
90
|
-
end
|
|
91
|
-
|
|
92
|
-
# Returns a [callback, value] array of all callbacks of +type+ for which an
|
|
93
|
-
# id was given.
|
|
94
|
-
|
|
95
|
-
def all_of_type(type)
|
|
96
|
-
a = []
|
|
97
|
-
@callbacks.all_of_type(type).each {|id, callback|
|
|
98
|
-
a << [callback, @ids_and_values[id]] if @ids_and_values.include?(id)
|
|
99
|
-
}
|
|
100
|
-
return a
|
|
101
|
-
end
|
|
102
|
-
|
|
103
|
-
end
|
|
104
|
-
|
|
105
|
-
# A serializable callback.
|
|
106
|
-
class Wee::LiteralMethodCallback
|
|
107
|
-
attr_reader :obj
|
|
108
|
-
|
|
109
|
-
def initialize(obj, method_id=:call, *args)
|
|
110
|
-
@obj, @method_id = obj, method_id
|
|
111
|
-
@args = args unless args.empty?
|
|
112
|
-
end
|
|
113
|
-
|
|
114
|
-
def call(*args)
|
|
115
|
-
if @args
|
|
116
|
-
@obj.send(@method_id, *(@args+args))
|
|
117
|
-
else
|
|
118
|
-
@obj.send(@method_id, *args)
|
|
119
|
-
end
|
|
120
|
-
end
|
|
121
|
-
end
|
data/lib/wee/core/component.rb
DELETED
|
@@ -1,356 +0,0 @@
|
|
|
1
|
-
# The base class of all components. You should at least overwrite method
|
|
2
|
-
# #render in your own subclasses.
|
|
3
|
-
|
|
4
|
-
class Wee::Component < Wee::Presenter
|
|
5
|
-
|
|
6
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
7
|
-
# :section: Render
|
|
8
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
9
|
-
|
|
10
|
-
public
|
|
11
|
-
|
|
12
|
-
# Starts rendering the decoration chain by calling method Presenter#do_render
|
|
13
|
-
# for the first decoration of the component, or calling <i>do_render</i> for
|
|
14
|
-
# the component itself if no decorations were specified.
|
|
15
|
-
#
|
|
16
|
-
# [+rendering_context+]
|
|
17
|
-
# An object of class RenderingContext
|
|
18
|
-
|
|
19
|
-
def do_render_chain(rendering_context)
|
|
20
|
-
decoration.do_render(rendering_context)
|
|
21
|
-
end
|
|
22
|
-
|
|
23
|
-
# This method renders the content of this component.
|
|
24
|
-
#
|
|
25
|
-
# *OVERWRITE* this method in your own component class to implement the
|
|
26
|
-
# view. By default this method does nothing!
|
|
27
|
-
#
|
|
28
|
-
# Use the current renderer as returned by #renderer or it's short-cut #r.
|
|
29
|
-
|
|
30
|
-
def render
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
34
|
-
# :section: Callback
|
|
35
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
36
|
-
|
|
37
|
-
public
|
|
38
|
-
|
|
39
|
-
# Starts processing the callbacks for the decoration chain by invoking method
|
|
40
|
-
# #process_callbacks of the first decoration or the component itself if no
|
|
41
|
-
# decorations were specified.
|
|
42
|
-
#
|
|
43
|
-
# [+block+]
|
|
44
|
-
# Specifies the action to be taken (e.g. whether to invoke input or action
|
|
45
|
-
# callbacks).
|
|
46
|
-
|
|
47
|
-
def process_callbacks_chain(&block)
|
|
48
|
-
decoration.process_callbacks(&block)
|
|
49
|
-
end
|
|
50
|
-
|
|
51
|
-
# Process and invoke all callbacks specified for this component and all of
|
|
52
|
-
# it's child components.
|
|
53
|
-
#
|
|
54
|
-
# [+block+]
|
|
55
|
-
# Specifies the action to be taken (e.g. whether to invoke input or action
|
|
56
|
-
# callbacks).
|
|
57
|
-
|
|
58
|
-
def process_callbacks(&block)
|
|
59
|
-
block.call(self)
|
|
60
|
-
|
|
61
|
-
# process callbacks of all children
|
|
62
|
-
children.each do |child|
|
|
63
|
-
child.process_callbacks_chain(&block)
|
|
64
|
-
end
|
|
65
|
-
end
|
|
66
|
-
|
|
67
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
68
|
-
# :section: Init
|
|
69
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
70
|
-
|
|
71
|
-
protected
|
|
72
|
-
|
|
73
|
-
# Initializes a newly created component.
|
|
74
|
-
#
|
|
75
|
-
# Call this method from your own components' <i>initialize</i> method using
|
|
76
|
-
# +super+, before setting up anything else!
|
|
77
|
-
|
|
78
|
-
def initialize() # :notnew:
|
|
79
|
-
@__decoration = Wee::ValueHolder.new(self)
|
|
80
|
-
@__children = []
|
|
81
|
-
end
|
|
82
|
-
|
|
83
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
84
|
-
# :section: Children/Composite
|
|
85
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
86
|
-
|
|
87
|
-
protected
|
|
88
|
-
|
|
89
|
-
# Returns all direct child components collected in an array.
|
|
90
|
-
#
|
|
91
|
-
# You can overwrite this method to return all direct child components of this
|
|
92
|
-
# component.
|
|
93
|
-
|
|
94
|
-
def children
|
|
95
|
-
@__children
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
# Add a child to the component. Example:
|
|
99
|
-
#
|
|
100
|
-
# class YourComponent < Wee::Component
|
|
101
|
-
# def initialize
|
|
102
|
-
# super()
|
|
103
|
-
# add_child ChildComponent.new
|
|
104
|
-
# end
|
|
105
|
-
# end
|
|
106
|
-
#
|
|
107
|
-
# If you dynamically add child components to a component at run-time (not in
|
|
108
|
-
# initialize), then you should consider to backtrack the children array (of
|
|
109
|
-
# course only if you want backtracking at all):
|
|
110
|
-
#
|
|
111
|
-
# def backtrack_state(snapshot)
|
|
112
|
-
# super
|
|
113
|
-
# snapshot.add(self.children)
|
|
114
|
-
# end
|
|
115
|
-
#
|
|
116
|
-
|
|
117
|
-
def add_child(child)
|
|
118
|
-
self.children << child
|
|
119
|
-
child
|
|
120
|
-
end
|
|
121
|
-
|
|
122
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
123
|
-
# :section: Decoration
|
|
124
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
125
|
-
|
|
126
|
-
public
|
|
127
|
-
|
|
128
|
-
# Returns the first decoration from the component's decoration chain, or
|
|
129
|
-
# +self+ if no decorations were specified for the component.
|
|
130
|
-
|
|
131
|
-
def decoration
|
|
132
|
-
@__decoration.value
|
|
133
|
-
end
|
|
134
|
-
|
|
135
|
-
# Set the pointer to the first decoration to +d+.
|
|
136
|
-
|
|
137
|
-
def decoration=(d)
|
|
138
|
-
@__decoration.value = d
|
|
139
|
-
end
|
|
140
|
-
|
|
141
|
-
# Iterates over all decorations (note that the component itself is excluded).
|
|
142
|
-
|
|
143
|
-
def each_decoration # :yields: decoration
|
|
144
|
-
d = self.decoration
|
|
145
|
-
loop do
|
|
146
|
-
break if d == self or d.nil?
|
|
147
|
-
yield d
|
|
148
|
-
d = d.owner
|
|
149
|
-
end
|
|
150
|
-
end
|
|
151
|
-
|
|
152
|
-
# Adds decoration +d+ to the decoration chain.
|
|
153
|
-
#
|
|
154
|
-
# A global decoration is added in front of the decoration chain, a local
|
|
155
|
-
# decoration is added in front of all other local decorations but after all
|
|
156
|
-
# global decorations.
|
|
157
|
-
#
|
|
158
|
-
# Returns: +self+
|
|
159
|
-
|
|
160
|
-
def add_decoration(d)
|
|
161
|
-
if d.global?
|
|
162
|
-
d.owner = self.decoration
|
|
163
|
-
self.decoration = d
|
|
164
|
-
else
|
|
165
|
-
last_global = nil
|
|
166
|
-
each_decoration {|i|
|
|
167
|
-
if i.global?
|
|
168
|
-
last_global = i
|
|
169
|
-
else
|
|
170
|
-
break
|
|
171
|
-
end
|
|
172
|
-
}
|
|
173
|
-
if last_global.nil?
|
|
174
|
-
# no global decorations specified -> add in front
|
|
175
|
-
d.owner = self.decoration
|
|
176
|
-
self.decoration = d
|
|
177
|
-
else
|
|
178
|
-
# add after last_global
|
|
179
|
-
d.owner = last_global.owner
|
|
180
|
-
last_global.owner = d
|
|
181
|
-
end
|
|
182
|
-
end
|
|
183
|
-
|
|
184
|
-
return self
|
|
185
|
-
end
|
|
186
|
-
|
|
187
|
-
# Remove decoration +d+ from the decoration chain.
|
|
188
|
-
#
|
|
189
|
-
# Returns the removed decoration or +nil+ if it did not exist in the
|
|
190
|
-
# decoration chain.
|
|
191
|
-
|
|
192
|
-
def remove_decoration(d)
|
|
193
|
-
if d == self.decoration # 'd' is in front
|
|
194
|
-
self.decoration = d.owner
|
|
195
|
-
else
|
|
196
|
-
last_decoration = self.decoration
|
|
197
|
-
next_decoration = nil
|
|
198
|
-
loop do
|
|
199
|
-
return nil if last_decoration == self or last_decoration.nil?
|
|
200
|
-
next_decoration = last_decoration.owner
|
|
201
|
-
break if d == next_decoration
|
|
202
|
-
last_decoration = next_decoration
|
|
203
|
-
end
|
|
204
|
-
last_decoration.owner = d.owner
|
|
205
|
-
end
|
|
206
|
-
d.owner = nil # decoration 'd' no longer is an owner of anything!
|
|
207
|
-
return d
|
|
208
|
-
end
|
|
209
|
-
|
|
210
|
-
# Remove all decorations that match the block condition.
|
|
211
|
-
#
|
|
212
|
-
# Example (removes all decorations of class +HaloDecoration+):
|
|
213
|
-
#
|
|
214
|
-
# remove_decoration_if {|d| d.class == HaloDecoration}
|
|
215
|
-
#
|
|
216
|
-
|
|
217
|
-
def remove_decoration_if # :yields: decoration
|
|
218
|
-
to_remove = []
|
|
219
|
-
each_decoration {|d| to_remove << d if yield d}
|
|
220
|
-
to_remove.each {|d| remove_decoration(d)}
|
|
221
|
-
end
|
|
222
|
-
|
|
223
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
224
|
-
# :section: Backtrack
|
|
225
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
226
|
-
|
|
227
|
-
public
|
|
228
|
-
|
|
229
|
-
# Starts the backtrack-state phase for the decoration chain, by invoking
|
|
230
|
-
# method #backtrack_state of the first decoration or the component itself if
|
|
231
|
-
# no decorations were specified.
|
|
232
|
-
#
|
|
233
|
-
# See #backtrack_state for details.
|
|
234
|
-
#
|
|
235
|
-
# [+snapshot+]
|
|
236
|
-
# An object of class Snapshot
|
|
237
|
-
|
|
238
|
-
def backtrack_state_chain(snapshot)
|
|
239
|
-
decoration.backtrack_state(snapshot)
|
|
240
|
-
end
|
|
241
|
-
|
|
242
|
-
# Take snapshots of objects that should correctly be backtracked.
|
|
243
|
-
#
|
|
244
|
-
# Backtracking means that you can go back in time of the components' state.
|
|
245
|
-
# Therefore it is neccessary to take snapshots of those objects that want to
|
|
246
|
-
# participate in backtracking. Taking snapshots of the whole component tree
|
|
247
|
-
# would be too expensive and unflexible. Note that methods
|
|
248
|
-
# <i>take_snapshot</i> and <i>restore_snapshot</i> are called for those
|
|
249
|
-
# objects to take the snapshot (they behave like <i>marshal_dump</i> and
|
|
250
|
-
# <i>marshal_load</i>). Overwrite them if you want to define special
|
|
251
|
-
# behaviour.
|
|
252
|
-
#
|
|
253
|
-
# By default only <tt>@__decoration</tt> is backtracked (which actually is a
|
|
254
|
-
# ValueHolder, as only the pointer changes not the decoration-object
|
|
255
|
-
# itself!).
|
|
256
|
-
#
|
|
257
|
-
# For example if you dynamically add children to your component, you might
|
|
258
|
-
# want to backtrack the children array. Therefore you simply pass it to the
|
|
259
|
-
# Snapshot#add method:
|
|
260
|
-
#
|
|
261
|
-
# def backtrack_state(snapshot)
|
|
262
|
-
# super
|
|
263
|
-
# snapshot.add(self.children)
|
|
264
|
-
# end
|
|
265
|
-
#
|
|
266
|
-
# This will call Array#take_snapshot to take the snapshot for the children
|
|
267
|
-
# array. If at a later point in time a snapshot is restored,
|
|
268
|
-
# Array#restore_snapshot will be called with the return value of
|
|
269
|
-
# Array#take_snapshot as argument.
|
|
270
|
-
#
|
|
271
|
-
# [+snapshot+]
|
|
272
|
-
# An object of class Snapshot
|
|
273
|
-
|
|
274
|
-
def backtrack_state(snapshot)
|
|
275
|
-
snapshot.add(@__decoration)
|
|
276
|
-
children.each do |child| child.backtrack_state_chain(snapshot) end
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
280
|
-
# :section: Call/Answer
|
|
281
|
-
# - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
282
|
-
|
|
283
|
-
protected
|
|
284
|
-
|
|
285
|
-
# Call another component. The calling component is neither rendered nor are
|
|
286
|
-
# it's callbacks processed until the called component answers using method
|
|
287
|
-
# #answer.
|
|
288
|
-
#
|
|
289
|
-
# [+component+]
|
|
290
|
-
# The component to be called.
|
|
291
|
-
#
|
|
292
|
-
# [+return_callback+]
|
|
293
|
-
# Is invoked when the called component answers.
|
|
294
|
-
# Either a symbol or any object that responds to #call. If it's a symbol,
|
|
295
|
-
# then the corresponding method of the current component will be called.
|
|
296
|
-
#
|
|
297
|
-
# [+args+]
|
|
298
|
-
# Arguments that are passed to the +return_callback+ before the 'onanswer'
|
|
299
|
-
# arguments.
|
|
300
|
-
#
|
|
301
|
-
# <b>How it works</b>
|
|
302
|
-
#
|
|
303
|
-
# The component to be called is wrapped with an AnswerDecoration and the
|
|
304
|
-
# +return_callback+ parameter is assigned to it's +on_answer+ attribute (not
|
|
305
|
-
# directly as there are cleanup actions to be taken before the
|
|
306
|
-
# +return_callback+ can be invoked, hence we wrap it in the OnAnswer class).
|
|
307
|
-
# Then a Delegate decoration is added to the calling component (self), which
|
|
308
|
-
# delegates to the component to be called (+component+).
|
|
309
|
-
#
|
|
310
|
-
# Then we unwind the calling stack back to the Session by throwing
|
|
311
|
-
# <i>:wee_abort_callback_processing</i>. This means, that there is only ever
|
|
312
|
-
# one action callback invoked per request. This is not neccessary, we could
|
|
313
|
-
# simply omit this, but then we'd break compatibility with the implementation
|
|
314
|
-
# using continuations.
|
|
315
|
-
#
|
|
316
|
-
# When at a later point in time the called component invokes #answer, this
|
|
317
|
-
# will throw a <i>:wee_answer</i> exception which is catched in the
|
|
318
|
-
# AnswerDecoration. The AnswerDecoration then invokes the +on_answer+
|
|
319
|
-
# callback which cleans up the decorations we added during #call, and finally
|
|
320
|
-
# passes control to the +return_callback+.
|
|
321
|
-
#
|
|
322
|
-
|
|
323
|
-
def call(component, return_callback=nil, *args)
|
|
324
|
-
add_decoration(delegate = Wee::Delegate.new(component))
|
|
325
|
-
component.add_decoration(answer = Wee::AnswerDecoration.new)
|
|
326
|
-
answer.on_answer = OnAnswer.new(self, component, delegate, answer,
|
|
327
|
-
return_callback, args)
|
|
328
|
-
throw :wee_abort_callback_processing, nil
|
|
329
|
-
end
|
|
330
|
-
|
|
331
|
-
class OnAnswer < Struct.new(:calling_component, :called_component, :delegate,
|
|
332
|
-
:answer, :return_callback, :args)
|
|
333
|
-
|
|
334
|
-
def call(*answer_args)
|
|
335
|
-
calling_component.remove_decoration(delegate)
|
|
336
|
-
called_component.remove_decoration(answer)
|
|
337
|
-
return if return_callback.nil?
|
|
338
|
-
if return_callback.respond_to?(:call)
|
|
339
|
-
return_callback.call(*(args + answer_args))
|
|
340
|
-
else
|
|
341
|
-
calling_component.send(return_callback, *(args + answer_args))
|
|
342
|
-
end
|
|
343
|
-
end
|
|
344
|
-
end
|
|
345
|
-
|
|
346
|
-
# Return from a called component.
|
|
347
|
-
#
|
|
348
|
-
# NOTE that #answer never returns.
|
|
349
|
-
#
|
|
350
|
-
# See #call for a detailed description of the call/answer mechanism.
|
|
351
|
-
|
|
352
|
-
def answer(*args)
|
|
353
|
-
throw :wee_answer, args
|
|
354
|
-
end
|
|
355
|
-
|
|
356
|
-
end
|