Class: Aquarium::Aspects::AfterAdviceChainNode
- Inherits:
-
AdviceChainNode
- Object
- AdviceChainNode
- Aquarium::Aspects::AfterAdviceChainNode
- Defined in:
- lib/aquarium/aspects/advice.rb
Constant Summary
Constants inherited from AdviceChainNode
Aquarium::Aspects::AdviceChainNode::NIL_OBJECT
Instance Method Summary collapse
- #advice_wrapper(jp) ⇒ Object
-
#initialize(options = {}) ⇒ AfterAdviceChainNode
constructor
A new instance of AfterAdviceChainNode.
Methods inherited from AdviceChainNode
#call, #call_advice, #each, #empty?, #invoke_original_join_point, #last, #size
Constructor Details
#initialize(options = {}) ⇒ AfterAdviceChainNode
Returns a new instance of AfterAdviceChainNode.
231 232 233 |
# File 'lib/aquarium/aspects/advice.rb', line 231 def initialize = {} super end |
Instance Method Details
#advice_wrapper(jp) ⇒ Object
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 |
# File 'lib/aquarium/aspects/advice.rb', line 234 def advice_wrapper jp # call_advice is invoked in each bloc, rather than once in an "ensure" clause, so the invocation in # the rescue clause can allow the advice to change the exception that will be raised. begin returned_value = next_node.call jp update_current_context jp jp.context.advice_kind = :after jp.context.returned_value = returned_value call_advice jp result = jp.context.returned_value # allow advice to modify the returned value reset_current_context jp result rescue Object => raised_exception update_current_context jp jp.context.advice_kind = :after jp.context.raised_exception = raised_exception call_advice jp raised_exception = jp.context.raised_exception # allow advice to modify the raised exception reset_current_context jp raise raised_exception end end |