Class: Wee::AnswerDecoration
- Inherits:
-
Decoration
- Object
- Presenter
- Decoration
- Wee::AnswerDecoration
- Defined in:
- lib/wee/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.
Defined Under Namespace
Classes: Answer, Interceptor
Instance Attribute Summary collapse
-
#answer_callback ⇒ Object
Returns the value of attribute answer_callback.
Attributes inherited from Decoration
Instance Method Summary collapse
-
#process_callbacks(callbacks) ⇒ Object
When a component answers,
@answer_callback.call(answer)
will be executed, whereanswer
is of class Answer which includes the arguments passed to Component#answer.
Methods inherited from Decoration
#global?, #render!, #render_presenter!, #state
Methods inherited from Presenter
#render, #render!, #renderer_class, #state
Instance Attribute Details
#answer_callback ⇒ Object
Returns the value of attribute answer_callback.
127 128 129 |
# File 'lib/wee/decoration.rb', line 127 def answer_callback @answer_callback end |
Instance Method Details
#process_callbacks(callbacks) ⇒ Object
When a component answers, @answer_callback.call(answer)
will be executed, where answer
is of class Answer which includes the arguments passed to Component#answer.
149 150 151 152 153 154 155 |
# File 'lib/wee/decoration.rb', line 149 def process_callbacks(callbacks) if action_callback = super Interceptor.new(action_callback, @answer_callback) else nil end end |