Class: Wee::ComponentRunner
Overview
Wee::ComponentRunner wraps a root component and provides methods that act on the components tree defined by the root component.
Direct Known Subclasses
Constant Summary collapse
- DEFAULT_CALLBACK_PROCESSING =
Values are parameters to method #process_callbacks_of
[ # Invokes all specified input callbacks. NOTE: Input callbacks should never # call other components! [:input, true, false], # Invokes the first found action callback. NOTE: Only the first action # callback is invoked. Any other action callback is ignored. [:action, false, true], # Invoke live_update callback (NOTE: only the first is invoked). [:live_update, false, true] ]
Instance Attribute Summary collapse
-
#root_component ⇒ Object
Returns the value of attribute root_component.
Instance Method Summary collapse
-
#initialize(root_component) ⇒ ComponentRunner
constructor
A new instance of ComponentRunner.
-
#process_callbacks(callback_stream) ⇒ Object
This method triggers several tree traversals to process the callbacks of the root component.
-
#render(rendering_context) ⇒ Object
Render the root component with the given rendering context.
-
#snapshot ⇒ Object
This method takes a snapshot from the current state of the root component and returns it.
Constructor Details
#initialize(root_component) ⇒ ComponentRunner
Returns a new instance of ComponentRunner.
23 24 25 26 |
# File 'lib/wee/core/componentrunner.rb', line 23 def initialize(root_component) @root_component = root_component @callback_processing = DEFAULT_CALLBACK_PROCESSING end |
Instance Attribute Details
#root_component ⇒ Object
Returns the value of attribute root_component.
21 22 23 |
# File 'lib/wee/core/componentrunner.rb', line 21 def root_component @root_component end |
Instance Method Details
#process_callbacks(callback_stream) ⇒ Object
This method triggers several tree traversals to process the callbacks of the root component.
Returns nil or a Response object in case of a premature response.
47 48 49 50 51 52 53 54 55 56 |
# File 'lib/wee/core/componentrunner.rb', line 47 def process_callbacks(callback_stream) if callback_stream.all_of_type(:action).size > 1 raise "Not allowed to specify more than one action callback" end catch(:wee_abort_callback_processing) { @callback_processing.each {|args| process_callbacks_of(callback_stream, *args) } nil } end |
#render(rendering_context) ⇒ Object
Render the root component with the given rendering context.
38 39 40 |
# File 'lib/wee/core/componentrunner.rb', line 38 def render(rendering_context) @root_component.do_render_chain(rendering_context) end |