Class: Wee::AnswerDecoration
- Inherits:
-
Decoration
- Object
- Presenter
- Decoration
- Wee::AnswerDecoration
- Defined in:
- lib/wee/core/decoration.rb
Overview
A Wee::AnswerDecoration is wrapped around a component that will call Component#answer. This makes it possible to use such components without the need to call them (Component#call), e.g. as child components of other components.
Instance Attribute Summary collapse
-
#on_answer ⇒ Object
When a component answers,
on_answer.call(args)will be executed (unless nil), whereargsare the arguments passed to Component#answer.
Attributes inherited from Decoration
Instance Method Summary collapse
Methods inherited from Decoration
#backtrack_state, #do_render, #global?, #restore_snapshot, #take_snapshot
Methods inherited from Presenter
#backtrack_state, #do_render, #get_property, #lookup_property, #properties, #properties=, #render, #session, template, uses_property
Instance Attribute Details
#on_answer ⇒ Object
When a component answers, on_answer.call(args) will be executed (unless nil), where args are the arguments passed to Component#answer. Note that no snapshot of on_answer is taken, so you should avoid modifying it!
129 130 131 |
# File 'lib/wee/core/decoration.rb', line 129 def on_answer @on_answer end |
Instance Method Details
#process_callbacks(&block) ⇒ Object
131 132 133 134 135 136 137 |
# File 'lib/wee/core/decoration.rb', line 131 def process_callbacks(&block) args = catch(:wee_answer) { super; nil } if args != nil # return to the calling component @on_answer.call(*args) if @on_answer end end |