Class: Aquarium::Aspects::AfterReturningAdviceChainNode

Inherits:
AdviceChainNode show all
Defined in:
lib/aquarium/aspects/advice.rb

Constant Summary

Constants inherited from AdviceChainNode

Aquarium::Aspects::AdviceChainNode::NIL_OBJECT

Instance Method Summary collapse

Methods inherited from AdviceChainNode

#call, #call_advice, #each, #empty?, #invoke_original_join_point, #last, #size

Constructor Details

#initialize(options = {}) ⇒ AfterReturningAdviceChainNode

Returns a new instance of AfterReturningAdviceChainNode.



183
184
185
# File 'lib/aquarium/aspects/advice.rb', line 183

def initialize options = {}
  super options
end

Instance Method Details

#advice_wrapper(jp) ⇒ Object



186
187
188
189
190
191
192
193
194
195
# File 'lib/aquarium/aspects/advice.rb', line 186

def advice_wrapper jp
  returned_value = next_node.call jp
  update_current_context jp
  jp.context.advice_kind = :after_returning
  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
end