class Aquarium::Aspects::AfterAdviceChainNode

Public Class Methods

new(options = {}) click to toggle source
Calls superclass method Aquarium::Aspects::AdviceChainNode::new
    # File lib/aquarium/aspects/advice.rb
233 def initialize options = {}
234   super options
235 end

Public Instance Methods

advice_wrapper(jp) click to toggle source
    # File lib/aquarium/aspects/advice.rb
236 def advice_wrapper jp
237   # call_advice is invoked in each bloc, rather than once in an "ensure" clause, so the invocation in
238   # the rescue clause can allow the advice to change the exception that will be raised.
239   begin
240     returned_value = next_node.call jp
241     update_current_context jp
242     jp.context.advice_kind = :after
243     jp.context.returned_value = returned_value
244     call_advice jp
245     result = jp.context.returned_value   # allow advice to modify the returned value
246     reset_current_context jp
247     result
248   rescue Object => raised_exception
249     update_current_context jp
250     jp.context.advice_kind = :after
251     jp.context.raised_exception = raised_exception
252     call_advice jp
253     raised_exception = jp.context.raised_exception   # allow advice to modify the raised exception
254     reset_current_context jp
255     raise raised_exception
256   end
257 end