Class Aquarium::Aspects::AfterAdviceChainNode
In: lib/aquarium/aspects/advice.rb
Parent: AdviceChainNode

Methods

Public Class methods

[Source]

     # File lib/aquarium/aspects/advice.rb, line 217
217:       def initialize options = {}
218:         super options
219:       end

Public Instance methods

[Source]

     # File lib/aquarium/aspects/advice.rb, line 220
220:       def advice_wrapper jp
221:         # call_advice is invoked in each bloc, rather than once in an "ensure" clause, so the invocation in 
222:         # the rescue clause can allow the advice to change the exception that will be raised.
223:         begin
224:           returned_value = next_node.call jp
225:           update_current_context jp
226:           jp.context.advice_kind = :after
227:           jp.context.returned_value = returned_value
228:           call_advice jp
229:           result = jp.context.returned_value   # allow advice to modify the returned value
230:           reset_current_context jp
231:           result
232:         rescue Object => raised_exception
233:           update_current_context jp
234:           jp.context.advice_kind = :after
235:           jp.context.raised_exception = raised_exception
236:           call_advice jp
237:           raised_exception = jp.context.raised_exception   # allow advice to modify the raised exception
238:           reset_current_context jp
239:           raise raised_exception
240:         end
241:       end

[Validate]