class Aquarium::Aspects::AfterAdviceChainNode

Public Class Methods

new(options = {}) click to toggle source
# File lib/aquarium/aspects/advice.rb, line 231
def initialize options = {}
  super options
end

Public Instance Methods

advice_wrapper(jp) click to toggle source
# 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